Hiieee...der
I am writin a somethin where I require to get string from the user anr then tokenise it.Can some1 give me some ideas on how to get started.I need the string to be in a loop as well.

fgets to get the string, strtok to tokenize it. To do this multiple times, just put your code inside the body of a loop.

Well your requisites aren't clear so mention them in detail.

Apart from it you can initiate a char array and then get the input through simple scanf() function.

Then use strtok() with array address and space as delimiter to get the first token and then loop over and get the other tokens by using strtok() with NULL address and space as delimiter.

Both your requisites (or at least what i could make of them)are satisfied.

Apart from it you can initiate a char array and then get the input through simple scanf() function.

Scanf can look simple, but it actually does a lot of work under the hood which obviously will slow down your code. Also, it can cause lots of problems if you don't know exactly how it is matching input. It seems like a good idea at first but it is generally regarded as bad coding practice in most cases.

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
int count=0;
const int arraysize=100;
char name[arraysize];

cout<<"Enter your name: ";
gets(name);

int size=strlen(name);//find the size of your name

cout<<"\n\n"<<endl;

for(int i=0;i<size;i++)
{
switch(name)
{
case 'a':
case 'A':
count++;
break;

case 'e':
case 'E':
count++;
break;

case 'i':
case 'I':
count++;
break;

case 'o':
case 'O':
count++;
break;

case 'u':
case 'U':
count++;
break;
}
}

cout<<"The number of vowels in your name is: "<<count<<endl;

getch();
}

Comments
Nope
This question has already been answered. Start a new discussion instead.