home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

C++ abnormal program termination

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2648
Discussions: 200,966, Posts: 2,379,630, Members: 246,332
Old October 6th, 2003, 11:02 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Oct 2003
Posts: 1
C++ abnormal program termination

Can someone look at this code and tell me what is wrong with it?

I get the message.....

abnormal program termination!

I think it has to do with the while loop and the Substr function.

If I take out the while loop it will work but only on one line.



Code....
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <iomanip>
using namespace std;

int main ()
{
string inf;
string ouf;

cout << "What is the input file?\n";
cin >> inf; // Input File Name
cout << "What is the output file?\n";
cin >> ouf; // Output File Name

string Field;
string s;

ifstream fin(inf.c_str());
ofstream fout(ouf.c_str());

while (fin){

getline(fin, Field, '\n');

s = Field.substr(5, 16);

fout <<s <<endl; //output last name

} //End while loop
fin.close();
fout.close();

return 0;
}
jsmith1017 is offline   Reply With Quote
Old October 6th, 2003, 02:32 PM     #2 (permalink)
Member
 
Join Date: Apr 2002
Posts: 59
Without being able to compile and execute your program until I get home, ya I would take a look at that loop and your substr.

You have Visual Studio or another IDE? You should try out the debugger if you haven't already; it will be your new best friend.
JohnRoboto is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3007)
Forty-six years ago today (7)
Laptop with wireless problem. (12)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Internet Lost (5)
windows 7 problem (7)
windows vista security holes (15)
Point and Shoot Camera Suggestions. (6)
Is the PSU I received dead? (13)
radeon x850xt platinum & shader.. (6)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (11)
Recent Discussions
windows vista security holes (15)
Help getting around port 80 for camer.. (4)
Laptop with wireless problem. (12)
Open With ..... Win7 (2)
Internet Lost (5)
Skillsoft Network+ Study Software Que.. (9)
virus blocking exe. files (1)
Point and Shoot Camera Suggestions. (6)
CPU fan stops spinning randomly (11)
Nvidia GTX 260 problem (1)
Modern Warfare 2: Who Bought It? (65)
Is the PSU I received dead? (13)
Print spooler problem (16)
Kingston Bluetooth Dongle Driver (1)
Multiple Restarts Required at Boot (3)
webcam (0)
upgrade for hp a6101 (0)
tv not turn on-makes clicking sound (2)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
Ideal cheap graph card for PC-Gaming? (18)


All times are GMT -4. The time now is 02:15 PM.
TechIMO Copyright 2009 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