|
-
January 26th, 2010, 05:03 PM
#3
Re: Getline_input_to_int
Thanks for your quick reply, i get an error whilst compiling though.
Heres my code:
<code>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
ifstream diagram;
diagram.open("diagram.in");
string line;
int one;
int two;
getline(diagram, line);
one = atoi(line);
getline(diagram, line);
two = atoi(line);
system("PAUSE");
return 0;
}
</code>
The error i get is the following: error C2664: 'atoi' : cannot convert parameter 1 from 'std::string' to 'const char *'
- Neil.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|