Error Message Concerning Reading File From A Drive

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 1
Reputation: cgre0205 is an unknown quantity at this point 
Solved Threads: 0
cgre0205 cgre0205 is offline Offline
Newbie Poster

Error Message Concerning Reading File From A Drive

 
0
  #1
Dec 8th, 2004
I AM RUNNING A PROGRAM THAT DEALS WITH TEXT FILES IN NOTEPAD. I TYPE IN A FAKE SSN AND THE PROGRAM IS TO READ A LIST OF FILES FROM student course. I AM GETTING AN ERROR MESSAGE TELLING ME THAT PROGRAM CAN'T READ FILE. TWO EX OF SSN'S ARE 201235678 AND 123411234. THE FOLLOWING IS SOME OF THE PROGRAM

  1. #include <iostream.h>
  2. #include <iomanip.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5. #include <fstream.h>
  6. #include <ctype.h>
  7. #include <conio.h>
  8. #include <string.h>
  9.  
  10.  
  11. struct student
  12. {
  13. long stud;
  14. char lname[12];
  15. char fname[8];
  16. char mi[1];
  17. };
  18.  
  19. struct Books
  20. {
  21. char courseID[7];
  22. char title[50];
  23. double price;
  24. };
  25.  
  26. struct title
  27. {
  28. char courseid[7];
  29. char booktitle[50];
  30. };
  31.  
  32. struct clas
  33. {
  34. long studid;
  35. char subjid[7];
  36. };
  37.  
  38. int main () //Beginning of main
  39. {
  40. char chartest;
  41.  
  42. //reading file
  43. ifstream infile("a:studentcourse.txt");
  44.  
  45. clas *bol[200];
  46. title *pic[200];
  47. student *boc[200];
  48. Books *rec[200];
  49. long ID;
  50. int count=0;
  51. int couter =0;
  52. int cou = 0;
  53. char *hold[7];
  54.  
  55. //SET UP OUT STREAM FOR CURRENT OUTPUT
  56. cout << setprecision (2)
  57. << setiosflags (ios::fixed)
  58. << setiosflags (ios::showpoint);
  59.  
  60.  
  61.  
  62.  
  63. cout<<"\n\n\nENTER STUDENT ID (social security number)\n";
  64. cin >> ID;
  65.  
  66. //reading file
  67.  
  68. while (!infile.eof())
  69. {
  70. boc[count] = new student();
  71. infile>>boc[count]->stud>>boc[count]->lname>>boc[count]->fname
  72. >>boc[count]->mi;
  73. count++;
  74. }
  75.  
  76. for(int i = 0; i < count ; i++)
  77. {
  78. long temp;
  79.  
  80. if(temp == ID)
  81. {
  82. cout<<boc[i]->lname<<" "<<boc[i]->fname<<" "<<boc[i]->mi;
  83. }
  84. }
  85.  
  86. cout<<"\n\n"<<setw(15)<<"Enter Y to continue or N to Cancel.\n\n\n";
  87. cin>>chartest;
  88. if(chartest == 'n' || chartest == 'N')
  89. {
  90. getche();
  91. clrscr();
  92. return 0;
  93. }//endif
  94.  
  95. cout<<"\n\n\nStudent ID No:"<<setw(25)<<ID;"\n\n";
  96.  
  97. cout<<"\n\nYou are enrolled in the following classes:\n";
  98.  
  99. // reading file
  100. ifstream infile_fil ("a:studentcourse.txt");
  101.  
  102. if (infile_fil.fail())
  103. {
  104. cout<<"\nThere is a problem locating the input file a:studentcourse.txt.\n";
  105. cout<<"\nCheck that input file is on the correct drive\n";
  106. cout<<"\nand that the name of the file is spelled correctly.";
  107. exit (1) ;
  108.  
  109. }

I WOULD APPRECIATE IF I COULD GET A RESPONSE AS SOON AS POSSIBLE
Last edited by alc6379; Dec 8th, 2004 at 6:31 pm. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,334
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 234
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Error Message Concerning Reading File From A Drive

 
0
  #2
Dec 8th, 2004
It might be a little easier to look at your code if it were enclosed within [CODE][/CODE] tags.

Hmmm. You open a file and never close it, then you open it.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Error Message Concerning Reading File From A Drive

 
0
  #3
Dec 8th, 2004
Originally Posted by Dave Sinkula
It might be a little easier to look at your code if it were enclosed within [CODE][/CODE] tags.

Hmmm. You open a file and never close it, then you open it.
...I went ahead and added the tags, but what's the deal with ALL CAPS LATELY?
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,334
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 234
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Error Message Concerning Reading File From A Drive

 
0
  #4
Dec 8th, 2004
>what's the deal with ALL CAPS LATELY?

If you mean [CODE][/CODE], that's how they show up when you hit the button. And that's how they sit in my template text file. Plus sometimes it needs to be said a little louder.

If you meant this post, that was an attempt at sarcasm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Error Message Concerning Reading File From A Drive

 
0
  #5
Dec 8th, 2004
Originally Posted by Dave Sinkula
>what's the deal with ALL CAPS LATELY?

If you mean [CODE][/CODE], that's how they show up when you hit the button. And that's how they sit in my template text file. Plus sometimes it needs to be said a little louder.

If you meant this post, that was an attempt at sarcasm.
Oh... no no no... not you... I mean everyone else. Your capitalization habits are sane, AFAICT.
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC