Sorry to post something so simple, but I don't see what I'm doing wrong here.
char data[1024]; DWORD numRead; ReadFile(handle, data, 1024, &numRead, NULL); if (numRead > 0) printf(data, "%.5s");
My intention is to read data from a file and then print only 5 characters. However, it prints all 1024 characters, which contradicts what I read here . The goal, of course, is to do something like:
printf(data, "%.*s", numRead);
What am I doing wrong here?
c string formatting printf
Mike pateras
source share