Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Concatinating Two Strings

$
0
0
#include<stdio.h>
#include<conio.h>
void main()
{
char a[25],b[25];
int i, j, k=1;
 puts("Enter the string A");
 gets(a);fflush(stdin);
 puts("Enter the string B");
 gets(b);fflush(stdin);
 while(k<2){
for(i=0;i<25;i++)
         {
                          if(a[i]!='\0')
                          {printf("%c",a[i]);
                                        }
                                        }
                                        for(j=0;j<25;j++)
                                        {
                                                         if(b[j]!='\0')
                                                         {
                                                                       printf("%c",b[j]);
                                                                       }
                                                                       }k++;

                                                                       }
                                                                       getch();
                                                                       }

The program is about concatenating two string , the program successfully concatenates the strings but also prints some garbage value after the two string why so?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>