Hello. I'm just starting out in C++ and am trying to figure out how to split a users string input into individual words and then put each word into a slot in an array. I think it's going rather well, but I'm running into some problems, and it would be great if you could help! Please try not to make it TOO complicated, I'm still learning. =)
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
int main ()
{
ifstream DataBank;
DataBank.open("DataBank.txt",ios_base::app);
if(!DataBank.is_open()){
cout << "Sorry, the program is experiencing problems with the DataBank." << endl;
}else{
cout << "DataBank opened successfully!" << endl;
cout << "Type something to be processed." << endl;
}
while(!DataBank.eof()){
char str[1000];
cin >> str;
char * tok;
tok = strtok (str," ,.-");
int i;
for(i=0;i<10;i++){
string myArray[] = {tok+i};
cout << myArray[i] << endl;
}
}
system("PAUSE");
return 0;
}