home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1843
Discussions: 188,398, Posts: 2,243,595, Members: 232,629
Old December 7th, 2004, 12:53 AM   Digg it!   #1 (permalink)
Member
 
Join Date: Nov 2004
Posts: 56
while (! fin.eof)

what does this do?, while (! fin.eof). i wrote it in my notes but forgot why i wrote it down. please give detailed explanation if possible.

boogieman063 is offline   Reply With Quote
Old December 7th, 2004, 01:08 AM     #2 (permalink)
Fur ballin
 
Sixpac_XP's Avatar
 
Join Date: Oct 2001
Location: Victoria, BC
Posts: 4,371
is that C ?

Sixpac_XP is offline   Reply With Quote
Old December 7th, 2004, 01:09 AM     #3 (permalink)
Fur ballin
 
Sixpac_XP's Avatar
 
Join Date: Oct 2001
Location: Victoria, BC
Posts: 4,371
eof = end of file?

Sixpac_XP is offline   Reply With Quote
Old December 7th, 2004, 01:09 AM     #4 (permalink)
I am a banana!
 
originel's Avatar
 
Join Date: Jun 2002
Location: Texas Tech
Posts: 3,921
Send a message via AIM to originel
it just keeps looping until the end of a file has been found. Technically the while loop waits until the eof (end of file) character has been read. It's part of the standard library.
originel is offline   Reply With Quote
Old December 7th, 2004, 01:47 AM     #5 (permalink)
Member
 
Join Date: Nov 2004
Posts: 56
sorry, i was not specific enough, it is c++, and i know that if loops till the end of the file, i suppose i need like a simple example if possible.
boogieman063 is offline   Reply With Quote
Old December 7th, 2004, 10:45 AM     #6 (permalink)
I am a banana!
 
originel's Avatar
 
Join Date: Jun 2002
Location: Texas Tech
Posts: 3,921
Send a message via AIM to originel
Code:
void main()
{
     ifstream fin;
     char stuff;
     fin.open("myfile.txt");
     while(!fin.eof)
          fin>>stuff;
     fin.close();
}
originel is offline   Reply With Quote
Old December 7th, 2004, 11:15 AM     #7 (permalink)
Ultimate Member
 
Join Date: Oct 2003
Location: Aztec, New Mexico
Posts: 1,608
Send a message via AIM to MadMan2k Send a message via MSN to MadMan2k
You can use a variation of it to check if the file is there:

ifstream inFile(file.txt);
if(! inFile)
{
cout << "File not found" << endl;
}
__________________
jonbuder.com
MadMan2k is offline   Reply With Quote
Old December 7th, 2004, 11:32 AM     #8 (permalink)
Member
 
Join Date: Nov 2004
Posts: 56
void main()
{
ifstream fin;
char stuff; //could this be used to get number values too
fin.open("myfile.txt"); //or is it just for char.
while(!fin.eof)
fin>>stuff; //could i fin multiple values like fin>>num1>>num2
fin.close(); //and would can if so could the num1 be an int and
} //num2 be a float.

i'm working on a program and we are supposed to call a function to read two values 1st one is an int and 2nd one is a float. but we can only use a one line call routine two get both numbers, and i dont know what type to make the function because its returning both an int and a float.
also when i call the function i dont know how to make it equal both numbers like
employeeid=data_in(fin); //both id and sales are supposed to come from data_in
sales=data_in(fin); //id is an int and sales is a float but who knows how
//you do that.
boogieman063 is offline   Reply With Quote
Old December 7th, 2004, 11:55 AM     #9 (permalink)
Ultimate Member
 
Join Date: Oct 2003
Location: Aztec, New Mexico
Posts: 1,608
Send a message via AIM to MadMan2k Send a message via MSN to MadMan2k
C++ will read until it encounters a space or a tab, then skip to the next input variable, if one exists in the input statement.

If you declare an int object X, and a string object Y, and type:

inFile >> X >> Y

it will assign the integer value found at the beginning of the file to X, and the string object found after, to Y.
MadMan2k is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with notifying user of empty recordset in ASP Tekk Webmastering and Programming 3 May 19th, 2004 03:45 PM
Whaddya think...Photochopped? Martoch IMO Community 43 December 17th, 2003 12:31 AM
C++ abnormal program termination jsmith1017 Webmastering and Programming 1 October 6th, 2003 02:32 PM
I dont understand ASP :( HELP! Tekk Webmastering and Programming 9 August 27th, 2003 04:43 AM
ASP / Access etc... Agent_Embryo Webmastering and Programming 21 August 20th, 2003 05:51 AM

Most Active Discussions
Is It Just Me? (2905)
Unarmed man on his stomach shot by .. (6)
Misery Loves Company... (2144)
New Build ( Finally ) (6)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (444)
Upgrading RAM (6)
Recent Discussions
Partition Magic 7.0 (Unallocate.. (17)
For cheap price and good qualit.. (1)
Left 4 Dead Small Freezes (3)
RCA 52Inch HDTV wont turn on (4)
wishin i could edit my aol prof.. (0)
Sporadic internet connectivity (2)
Assassins Creed PC Problems (40)
I think my PSU is dieing (1)
building a gaming computer, inp.. (0)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 03:31 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28