Text Question.

Non-platform specific questions.

Postby Sgt. Sparky » Tue Jun 12, 2007 10:39 pm

Code: Select all
FILE*txt;
txt = fopen("textfile.txt", "r+");
fread(&temp, sizeof(temp), 1, txt);
fclose(txt);
strcpy(text, temp);

is a code that
will work. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Jay S. » Wed Jun 13, 2007 12:55 am

...Okay, the code is working!!! :D

...but it's displaying the whole text file. :shock:

Anyway to get it so it only displays a specified number of lines--as well as which line--from the file? This is the code I used:

Code: Select all
FILE*txt;
txt = fopen("textfile.txt", "r+");
fread(&temp, sizeof(temp), 1, txt);
fclose(txt);
strcpy(text, temp);
Last edited by Jay S. on Wed Jun 13, 2007 1:14 am, edited 1 time in total.
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby Sgt. Sparky » Wed Jun 13, 2007 11:15 am

Jay S. wrote:...Okay, the code is working!!! :D

...but it's displaying the whole text file. :shock:

Anyway to get it so it only displays a specified number of lines--as well as which line--from the file? This is the code I used:

Code: Select all
FILE*txt;
txt = fopen("textfile.txt", "r+");
fread(&temp, sizeof(temp), 1, txt);
fclose(txt);
strcpy(text, temp);

use my line selecting code at the end of that(put the line function in global though)
then you can select it to copy the specefied text by selecting the target to text. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Jay S. » Wed Jun 13, 2007 1:59 pm

Thank you for all your help, Sparky! :)
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby Sgt. Sparky » Thu Jun 14, 2007 2:03 pm

you are welcome. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest