Sujet : Re: Rationale for aligning data on even bytes in a Unix shell file?
De : vallor (at) *nospam* cultnix.org (vallor)
Groupes : comp.lang.cDate : 28. Apr 2025, 10:04:41
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vungb9$2hlca$2@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Pan/0.162 (Hmm4; 100b1318; Linux-6.14.4)
On Mon, 28 Apr 2025 01:21:39 -0000 (UTC), vallor <
vallor@cultnix.org>
wrote in <
vuml73$1riea$1@dont-email.me>:
ObC (What did I mess up here?):
Answer (I think?): the %x printf conversion expects an unsigned int.
$ cat readit.c
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
int main(void)
{
DIR * this = {0};
struct dirent * entry = {0};
char * s;
int dc = 0; // display character
this = opendir(".");
while ((entry = readdir(this))!=NULL)
{
if(!strcmp(entry->d_name,".")) continue;
if(!strcmp(entry->d_name,"..")) continue;
for(s = entry->d_name; *s ; s++)
{
dc = (*s<0) ? 256+*s : *s;
printf("%x\n",dc);
}
puts("---");
}
return 0;
-- -v