my code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
char str1[1000000];
char newString[1000][1000];
int i,j,ctr;
cout <<" \n\n Split string by space into words :"<< endl;
cout << "---------------------------------------\n";
cout << " Input a string : ";
cin >> str1 >> sizeof(str1) >> stdin;
j=0; ctr=0;
for(i=0;i<=(strlen(str1));i++)
{
// if space or NULL found, assign NULL into newString[ctr]
if(str1[i]==' '||str1[i]=='\0')
{
newString[ctr][j]='\0';
ctr++; //for next word
j=0; //for next word, init index to 0
}
else
{
newString[ctr][j]=str1[i];
j++;
}
}
cout << "\n Strings or words after split by space are :\n";
for(i=0;i < ctr;i++)
cout << newString[i];
return 0;
}
The error statement:
Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'unsigned int' (or there is no acceptable conversion) c:\users\ayah atiyeh\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\source.cpp 14 3 IntelliSense: no operator ">>" matches these operands operand types are: std::basic_istream> >> unsigned int c:\Users\Ayah Atiyeh\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\Source.cpp 14
std::string? BTW - What do you think the linecin >> str1 >> sizeof(str1) >> stdin;means? - Ed Heal>> sizeof(str1)what? - user2672107