STRTOK:
This function inputs an array from user and convert the given string into tokens or you can say convert every complete word into a different line.
#include <stdio.h>
using namespace std;
void strtok(char []);
int main()
{
char arr[200];
cout << "Enter the statement : " << endl;
gets(arr);
cout<<"After Converting statement into tokens: "<<endl;
strtok(arr);
return 0;
}
void strtok(char array[])
{
int i=0;
while(array[i]!='\0')
{
if(array[i]==' ')
{
cout<<endl;
}
else if(array[i]!='\0')
{
cout<<array[i];
}
i++;
}
}
This function inputs an array from user and convert the given string into tokens or you can say convert every complete word into a different line.
Here is the Code for this Program.>>>
#include <iostream>#include <stdio.h>
using namespace std;
void strtok(char []);
int main()
{
char arr[200];
cout << "Enter the statement : " << endl;
gets(arr);
cout<<"After Converting statement into tokens: "<<endl;
strtok(arr);
return 0;
}
void strtok(char array[])
{
int i=0;
while(array[i]!='\0')
{
if(array[i]==' ')
{
cout<<endl;
}
else if(array[i]!='\0')
{
cout<<array[i];
}
i++;
}
}
No comments:
Post a Comment