Tuesday, November 28, 2017

C++ Code Review: How to remove space within sentence.

Description: This program shows how to remove space within sentence.

Code:

//Compiling Tool: Code::Block IDE with MinGW

//Program shows how to remove space from sentence.

 

#include<iostream>

#include<stdio.h> //used for gets()

 

using namespace std;

 

int main()

{

    char str1[30],str2[30],str3[60];

    int i,j;

    cout<<"Enter first string:";

    gets(str1);

    cout<<"Enter second string:";

    gets(str2);

 

    for(i=0;str1[i]!='\0';++i)

        str3[i]=str1[i];

 

    for(j=0;str2[j]!='\0';++j)

        str3[i+j]=str2[j];

 

    str3[i+j]='\0';

 

    cout<<"\nThe concatenated string is "<<str3;

 

    return 0;

}       

 

Output:

 clip_image002

If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects. For book sample click this link.

Add your comments in below available comment box.

Note: Click these label/tags to view all related posts. Tags: C++Code

 

…till next post, bye-bye & take care.

No comments:

Post a Comment