Hi everyone, i wanted my program to create another small program, but it stopped at "\x00", why and what can i do. Thnaks

#include <stdio.h>
int main()
{
    FILE *out;
    out = fopen("c:\\cpy.exe", "wb");
    fprintf(out, "\xCD\x21\x00\xCD\x21");
    fclose(out);
    return 0;
}

Recommended Answers

All 2 Replies

Hi everyone, i wanted my program to create another small program, but it stopped at "\x00", why and what can i do. Thnaks

#include <stdio.h>
int main()
{
FILE *out;
out = fopen("c:\\cpy.exe", "wb");
fprintf(out, "\xCD\x21\x00\xCD\x21");
fclose(out);
return 0;
}

Because "\x00" terminates the string.

Use fwrite() instead, because there you give it the length of the string to output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.