I am trying to read and print from another file and reverse every line separately but I am only able to print out the lines and reverse the last line. Any suggestions on what I need to do to reverse every line in the file? *I cannot use strrev(), must keep its same format but reversed (i.e same capitalization, numbers, and symbols)
int main() {
int i=0, j, len;
char data[80]. rev[];
FILE *fp = fopen("fileread", "r");
// reads and prints out fileread
while(!feof(fp))){
fgets(data, 80, fp);
puts(data);
}
// reverse hopefully
while(data[++i] != '\0;);
while(i>=0);
rev[j++] = data[--j];
rev[j] = '\0';
printf("String Reversed: %s\n, rev);
fclose(fp0);
}
here is an example of what I want.
(file text)
Hello World!
I am $till around.
running @ Best Speedz
kayak
expected output:
!dlroW olleH
.dnuora llit$ ma I
zdeepS tseB @ gninnur
kayak