I am a quite inexperienced C programmer and am trying to write a simple program to add HTML line breaks to a text file. I actually got the program to compile but it gives me weird output.
Hello World of C Programming.
Here is my source code:
In my mind it is probably a simple little bug but I cant find it.
char* readLine(FILE *fp)
int tc, cnt = 0;
while ((tc = fgetc(fp)) != -1)
tmp = (char) tc;
if (tmp == '\n')
buffer1[cnt++] = tmp;
int main(int argc, char **argv)
char *tmp = malloc(sizeof(char) * 500);
char file, buffer = "";
printf("Enter the name of the file you wish to affect> ");
fl = fopen(file, "r");
while ((tmp = readLine(fl)) != NULL)
strcat(buffer, "<br /> \n");
fl = fopen(file, "w");
printf("Your file has been altered thanks for using webliner\n");
All help is greatly appreciated.