HELLO THIS IS MY FIRST POST.
I WISHED IF ANY ONE COULD HELP IN EXTRACTING WORDS FROM A CHAR ARRAY -STRING
LIKE IF THE SENTENCE INPUTTED BY USER - JACK WENT UP
THEN I NEED TO PRINT THESE WORDS SEPARATELY ON FRESH LINES
OUTPUT-
JACK
WENT
UP
I TRIED THIS BUT THIS IS NOT WORKING
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
char a[100];
int x;
cout<<" enter a sentence";
gets(a);
for(int x=0;a[x]!='\0';x++)
{
if(a[x]==' ')
{
for(int p=0;p<=x;p++)
cout<<a[p];
cout<<endl; }
}
}
the output produced is
JACK
JACK WENT
JACK WENT UP
JUST ONE MORE REQUEST THE PROGRAM SHOULD BE DONE ONLY BY SIMPLE CHAR TYPE ARRAYS PLEASE.
I HAVE TRIED THIS QUERY ON OTHER FORUMS BUT ALL ADVICED TO USE "STDL "STRINGS WHICH IS NOT IN MY COURSE.
YOU CAN USE MULTIDIMENSIONAL ARRAYS FOR STORING WORDS
HOPING FOR A SOLUTION