Hello,
I hope someone can help me, I'm a little bit stuck.
It's been a while since I did any coding and this project is designed to get me back into it.
Basically I want to take a string in from the user then break this string up into separate words, then store these words as an array of pointers to strings(or char arrays);
Here's what I have, it compiles and runs but gives an unhandled exception...
//code begin
#include <iostream>
#include <string.h>
using namespace std;
bool isalfa(char ch);
void Split_String(char * Origin, char * Destination_array);
int main()
{
char Array_Source[512];
char * Array_of_Char_Poiners[50];
cout<< "please enter a question string: \t";
cin.getline(Array_Source, 512);
Split_String(Array_Source, Array_of_Char_Poiners[50]);
for(int a=0; a<=50; a++)
cout << Array_of_Char_Poiners[a] << "\n";
return 0;
}
void Split_String(char * Origin, char * Destination_array){
char * p1;
int i, j, k = 0;
for(i=0; i<=512; i++){
if(!isalfa(Origin[i]))
i++;
p1=new char[50];
j=0;
if(isalfa(Origin[i])){
p1[j] = Origin[i];
j++;
}
}
}
bool isalfa(char ch){
if(ch>33 && ch<122)
return true;
else
return false;
}
//code ends



LinkBack URL
About LinkBacks



CornedBee