You've got a lot of problems with your code, but you do get bonus marks for being one of the few people who use code tags on their first post!
>#include<iostream.h>
>#include<string.h>
Those headers are nonstandard and not recommended. Try removing the ".h" from them and adding the line "using namespace std;" below them.
>#include<conio.h>
>#include<dos.h>
Old headers. Get rid of them.
>#include<stdio.h>
This is a C header. You shouldn't need or use it either.
>void main()
void main() is also nonstandard and bad. Use int main() instead.
>clrscr();
Don't clear the screen. It relies on those old headers, and annoys people like me who might actually have important data on the screen before you wiped it.
>char text1[]=" ";
You're only allocating 2 bytes (one for the space, one for the terminating null character) to hold an entire word. Nope, that's not a good idea.
Instead of using character arrays, consider using a C++ string. You don't need to worry about character allocation, and it makes your job a heck of a lot easier. If you're confident enough, you could even use string's built in searching functions to do the tokenizing instead of implementing your own.
>getch();
This relies on the nonstandard conio.h header. Try using getchar(); instead.
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
Offline 5,055 posts
since Apr 2006