i got a program thats get the newline...
i am able to get it vertical but im looking for the line to be horizontal.
so lets say my text has "this is an example \n = 1st line "
"i'm so crazy about c \n = 2st line"
my program only gets ti...first letter of 1st line and second line.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char *filename = "room.txt";
FILE *infile;
char line_buffer[100];
char newline;
infile = fopen(filename, "r");
if (!infile) {
printf("Couldn't open file %s for reading.\n", filename);
return 0;
}
printf("Opened file %s for reading.\n", filename);
newline= 0;
while (fgets(line_buffer, sizeof(line_buffer), infile)) {
++newline;
if(newline= 1)
{
printf("%c", line_buffer[0]);
}
}
fclose(infile);
return 0;
}