Reverse the strings by words

February 22, 2019
Reverse the strings by words
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char str[500];
    char strn[50][50];
    cout<<"Enter the string: ";
    cin.getline(str,500);
    int len = strlen(str);
       for(int x=0;str[x]!='\0';x++)
           {
                for(int i = 0; str[x]==' ';i++)
                {
                  strn[i][i] = str[x] ;
                  break;
                }

           }
       cout<<strn[0];
    return 0;
}

No comments:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
Powered by Blogger.