Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 19:30

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: reading Textfile and show it[winapi]
PostPosted: 05 Oct 2007 12:29 

Joined: 03 Oct 2007 18:41
Posts: 27
Location: Germany
hi,

do any1 know how to read a textfile and display it on C++ / WinAPI ?


datei = fopen ("testdatei.txt", "r");
if (datei != NULL)
{
fscanf (datei, "%100c", text);
printf ("%s\n", text); // How to make it on winAPI ??
fclose (datei);
}

Not really works cuz i don't know how to show it on winapi program.

I just wanna put that textfile http://golden2talon.go.funpic.de/checklist.txt into the program. That's all.

thx in advance


Top
 Profile  
 
 
 Post subject:
PostPosted: 05 Oct 2007 13:06 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
Depends by what you want to do exactly.

First let's see how to read the file after having called fopen():
- line per line:
char buff[1024];
while(fgets(buff, sizeof(buff), datei)) {
// buff will contain also the carriage return and the line feed used in the file
}
fclose(datei);

- all in memory:
struct stat xstat;
char *buff;
fstat(fileno(datei), &xstat);
buff = malloc(xstat.st_size + 1);
fread(buff, xstat.st_size, 1, datei);
buff[xstat.st_size] = 0;
fclose(datei);

Then, for the visualization you can use a MessageBox which is NOT an elegant solution but it's very simple, or you need to create a window in which visualizing this text (like I did in the message window of my q3dirtrav proof-of-concept).
An useful tutorial about the programming of the Windows gui is available here: http://winprog.org/tutorial/


Top
 Profile  
 
 Post subject:
PostPosted: 06 Oct 2007 08:48 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
hmm...not really sure what u mean, but ..
try using Notepad++ ?! ..it can show files in c++, c, perl, php....etc languages. Thats what i use to edit php, c++, perl ..etc files.

http://www.sx.brutalcore.co.uk/Files/no ... taller.exe


Top
 Profile  
 
 Post subject:
PostPosted: 06 Oct 2007 17:28 

Joined: 03 Oct 2007 18:41
Posts: 27
Location: Germany
lol , do you know what a Win32 Application Window is? Look's like that http://www.imgnow.de/uploads/image1c9dpng.png


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: