Look you the is***() functions -- isalpha() isdigit() ispunct() etc...
They are in the ctype (or ctypes, I can never remember) header
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
1) you can't use strcpy(). You are dealing with substring and this function is for full strings.
2) look up the functions I mentioned. They will make your life easier. Unless, of course, you like to string 15 conditionals inside 1 IF statement.
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
How about copying all of a type in one go:
while (Block[i])
{
while (isalpha(Block[i]))
{
Token[j][k] = Block [i];
k++;
i++;
Token[j][k] = '\0'; // be sure to 'end the string'
Type[j] = 1;
}
This will copy the entire word up to the first non-alpha character and leave you set at the following character.
A slightly cleaner option:
while (Block[i])
{
if (isalpha(Block[i]))
{
k = 0;
while (isalpha(Block[i]))
{
Token[j][k++] = Block [i++];
}
Token[j][k] = '\0'; // be sure to 'end the string'
Type[j] = 1;
}
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
Why don't you use the same technique i showed you for SPACEs, Numbers, and Punctuation? What I gave you was an example, not a complete answer. What if your 'sentence' is
Jonn Jonzz 2314 54th Street High Plains, Mars --- out for lunch!!!
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
@WaltP The way you showed me doesn't j++ so it would just keep replacing the same array
I wonder if there's a fix for that. I'm not going to do all your work. You still need to think. That's part of programming...
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
Question Answered as of 7 Months Ago by
WaltP,
np complete
and
Suzie999