Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 9th, 2007, 12:51 PM   #1
Lesliect6
Programmer
 
Join Date: Aug 2005
Posts: 68
Rep Power: 4 Lesliect6 is on a distinguished road
file reading anomaly

Hello,

I would like to know the cause of this anomaly in a recent code I made. The code opens a file, and reads the number of lines in it. It works with some files, and does not with others. The code snippet is the following :

...
#define NEXT_LINE 10
...
int main()
{
...
char c, str[256];
int lines=1;

ifstream fin;
cin >> str;
fin.open(str); 

while (fin.good())
{
    c=fin.get();
    if (c==NEXT_LINE) lines++;
}

cout << "The number of lines in the file : " << lines;
...

While this code works with a .txt and a .bak file I made for the program, it does not work with an .x and an .exe file. I don't know where I made the error, could you help me?

Thank you,
Leslie
Lesliect6 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnlineTextEditor.Com! Sane Show Off Your Open Source Projects 43 Jun 16th, 2006 9:55 AM
c++ reading from a file ... programmingnoob C++ 8 Apr 22nd, 2006 7:17 PM
reading in a file in java ryanl Java 3 Sep 8th, 2005 10:54 AM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 10:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 5:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:06 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC