#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
cout << "Enter a line: " << endl;
getline(cin, str);
for(size_type ix=0; ix!=str.size(); ++ix)
cout << str[ix] << endl;
return 0;
}
These are the errors I get :
E:\C++\MiniGW C++\String Character Fetch\main.cpp||In function 'int main()':| E:\C++\MiniGW C++\String Character Fetch\main.cpp|10|error: 'size_type' was not declared in this scope| E:\C++\MiniGW C++\String Character Fetch\main.cpp|10|error: expected ';' before 'ix'| E:\C++\MiniGW C++\String Character Fetch\main.cpp|10|error: 'ix' was not declared in this scope| ||=== Build finished: 3 errors, 0 warnings ===|
I can see the size_type is creating problem, but the book want's me to use the same !
I can see that size_t works, but are they the same?
Thanks !
This post has been edited by Jeet.in: 27 July 2011 - 09:59 PM

New Topic/Question
Reply





MultiQuote




|