how could i reverse the word in a DAT file without using link and append the reverse text in the DAT file.? any suggestions? i already tried reversing it using linked list but i want to try another program with out using link list
reverse of the text in a textfile...
Collapse
X
-
Did you try using pointers? You could just point a pointer to the start, and then at the end, and print the second and decrement until it reaches the first...Originally posted by sandra19how could i reverse the word in a DAT file without using link and append the reverse text in the DAT file.? any suggestions? i already tried reversing it using linked list but i want to try another program with out using link list -
here is the start of code... could you please (if its ok with you) to add a little of your ideas here...? i really dont know how to start it..Originally posted by sicarieDid you try using pointers? You could just point a pointer to the start, and then at the end, and print the second and decrement until it reaches the first...
file_ptr = fopen("FIRST.DA T","r");
if (file_ptr != NULL)
{
while ((buffer = fgetc (file_ptr)) != EOF)
printf("%c", buffer);
printf("\n");
fclose(file_ptr );
gotoxy(2,22);
printf("String has been successfully displayed on screen.");
getch();Comment
-
My ideas are going to be basic - you're trying to code when you dont' know what you're trying to code. You're also trying to code with horrible, broken, old, non-standard libraries. Never ever ever ever ever ever use conio.h.Originally posted by sandra19here is the start of code... could you please (if its ok with you) to add a little of your ideas here...? i really dont know how to start it..
file_ptr = fopen("FIRST.DA T","r");
if (file_ptr != NULL)
{
while ((buffer = fgetc (file_ptr)) != EOF)
printf("%c", buffer);
printf("\n");
fclose(file_ptr );
gotoxy(2,22);
printf("String has been successfully displayed on screen.");
getch();
So I would recommend creating your algorithm before you start coding. You can obviously get a line and print it out, but you don't even try to create a pointer, figure out the size of your string, point the pointer to the end of the string, and start decrementing and printing. So I would start there.Comment
-
i already have the code in revesing the text in a textfile... basically, i used pointers(just like what u said( but i cant put it here since i wrote the code on our school)... another problem is,, how could i put the data in the pointer back to the dat file again? after reversing it..ideas??? please??Comment
Comment