Can someone solve this problem for me?
Im trying to break a string into arrays of pairs... But the thing is an error will occur when this code is executed.
Code:
void letterPair(char str[])
{
int i;
int j;
int total = 0;
char temp[50][50];
char abc[1];
for(i = 0; str[i] != '\0'; i++)
{
if(!isspace(str[i]) )
{
if(!isspace(str[i+1]) )
{
if( str[i+1] != '\0' )
{
abc[0] = str[i];
abc[1] = str[i+1];
strcat(temp[total],abc);
total++;
}
}
}
}
}
More information:
Lets say my str = "THIS IS A STRING"
I want to break it up to "TH" "HI" "IS" "IS" "ST" "TR" "RI" "IN" "NG"
And im leaving out the pairs which have spaces. Eg " I" "S " " A" "A " and " S". (Pls note the spaces)
Or are there any other ways to join two characters together??Help is very much appreciated!! Thanks a lot!!