Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Need some Help with Spacing


  • Please log in to reply
No replies to this topic

#1 jelousdogs

jelousdogs

  • Members
  • 1 posts
  • OFFLINE
  •  
  • Local time:10:39 PM

Posted 31 March 2018 - 04:43 AM

Hey, guys I've got a school project about concatenating two strings. 

I have the program but I want to add spaces between the 2 strings after they're added.

for example, if one string is 'good' and other string is 'morning', it should be printed as good morning, whereas now it's being printed as  goodmorning.

 

this is my program.

 


//program to concatente two strings without using in build functions 
#include<stdio.h>
 
void main(void)
{
  char str1[25],str2[25];
  int i=0,j=0;
  printf("\nEnter First String:");
  gets(str1);
  printf("\nEnter Second String:");
  gets(str2);
  while(str1[i]!='\0')
  i++;
  while(str2[j]!='\0')
  {
    str1[i]=str2[j];
    j++;
    i++;
  }
 
  printf("\nConcatenated String is %s",str1);
}

Edited by jelousdogs, 31 March 2018 - 04:58 AM.


BC AdBot (Login to Remove)

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users