Subscribe Now: standard

Saturday, December 5, 2009

c++ source code to seperate or divide a string into words


This program will accept a string and divide it and store each word in a 2D array ,and  then display it.



you will need the following header files
conio.h

string.g
iostream.h

============================================
int main()
{clrscr();
    char tall[80],wrd[10][15];
    cout<<"Please enter your string\n:";
    cin.getline(tall,80);
    int r=0,c=0;
   
    for(int i=0;i
    {   c=0;
  
        while(tall[i]!=' ')
        {
            wrd[r][c++]=tall[i];
            i++;
        }
   
        if(tall[i]==' ')
        {
            wrd[r][c]='\0';
            r++;
        }
    }
clrscr();
    for(int i=0;i
    {
        cout<<"\n"<
    }

   }

------------------------------------------------------------------------------------------------
if you need any hel , feel free to get me at
tech support at http://blaisemcrowly.co.cc

No comments:

Post a Comment