I am trying to make a program that generates source code for a much larger program for simple reversal encryption. I don't know what I am doing wrong. Here is my code so far:

#include<stdio.h>
int main()
{
    FILE *fp;
fp=fopen("d:\\crypt.h", "w");

fprintf(fp, "char out[8];char cur[8];
        char con[255,255,255,255,255,255,255,255];/n
        if cur==con out==0,0,0,0,0,0,0,0;/n
        while(cur <= con) /n
            con=con-1/n

            if cur>=con out=out+1;

         ");
         return 0;
}

please help, thank you

Two things:

  1. String literals don't span lines. Provided there's nothing in between, you can make each line a string literal and they will be automatically concatenated onto one:

    fprintf(fp, 
        "char out[8];char cur[8];"
        "char con[255, 255, 255, 255, 255, 255, 255, 255];\n"
        "if cur == con out == 0, 0, 0, 0, 0, 0, 0, 0;\n"
        "while (cur <= con)\n"
        "    con = con - 1\n"
        "if cur >= con out = out + 1;");
    
  2. The "code" in your string is completely malformed and illegal C.

Thank you, I don't know what I am doing I am new to this. I thought that this would be a good way to learn to manipulate ASCII values.

Be a part of the DaniWeb community

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