c tutorial in telugu BUY TELUGU TUTORIAL DVD'S:::: SEO::3500/-,DCA(DOS,WINDOWS,WORD,EXCEL,POWER POINT, MS ACCESS, INTERNET CONCEPTS)::499/-,DTP(PHOTOSHOP,PAGEMAKER, CORELDRAW,TELUGU TYPING)::999/-,C::700,C++::900,TALLY ERP 9:: 999,ORACLE:999/-,CORE JAVA::1000/-,SPOKEN HINDI:500,HTML::500/-,AUTOCAD::2500/-,DCA+DTP::1000/-,DCA+TALLY::1000,C,C++,JAVA::1500, ALL COURSES(DCA,DTP,C,C++,JAVA,ORACLE,TALLY,HTML,SPOKEN HINDI,AUTOCAD):: 3500/-..CONTACT : SYED HAFIZ, SHOPPING COMPLEX,8INCLINE COLONY,GODAVARI KHANI,KARIMNAGAR, TELANGANA,CELL:9395306603,EMAIL:COOLHAFI7@GMAIL.COM.
Home / C / C tutorial in telugu about Strings Part 36

C tutorial in telugu about Strings Part 36

c tutorial in telugu

This c language telugu video tutorial explained you about String concatenate. and you can also fined string length telugu video tutorial here

This program concatenates strings, for example if the first string is “c ” and second string is “program” then on concatenating these two strings we get the string “c program”. To concatenate two strings we use strcat function of string.h, to concatenate without using library function see another code below which uses pointers.

C programming code

#include <stdio.h>
#include <string.h>
 
int main()
{
   char a[1000], b[1000];
 
   printf("Enter the first stringn");
   gets(a);
 
   printf("Enter the second stringn");
   gets(b);
 
   strcat(a,b);
 
   printf("String obtained on concatenation is %sn",a);
 
   return 0;
}

Concatenate strings without strcat function

C program to concatenate strings without using library function strcat of string.h header file. We create our own function.

#include <stdio.h>
 
void concatenate(char [], char []);
 
int main()
{
   char p[100], q[100];
 
   printf("Input a stringn");
   gets(p);
 
   printf("Input a string to concatenaten");
   gets(q);
 
   concatenate(p, q);
 
   printf("String obtained on concatenation is "%s"n", p);
 
   return 0;
}
 
void concatenate(char p[], char q[]) {
   int c, d;
 
   c = 0;
 
   while (p[c] != '�') {
      c++;
   }
 
   d = 0;
 
   while (q[d] != '�') {
      p[c] = q[d];
      d++;
      c++;
   }
 
   p[c] = '�';
}

The first for loop in concatenate function is calculating string length so you can also use strlen function if you wish.

String concatenation using pointers

#include <stdio.h>
 
void concatenate_string(char*, char*);
 
int main()
{
    char original[100], add[100];
 
    printf("Enter source stringn");
    gets(original);
 
    printf("Enter string to concatenaten");
    gets(add);
 
    concatenate_string(original, add);
 
    printf("String after concatenation is "%s"n", original);
 
    return 0;
}
 
void concatenate_string(char *original, char *add)
{
   while(*original)
      original++;
 
   while(*add)
   {
      *original = *add;
      add++;
      original++;
   }
   *original = '�';
}

About Hafiz

Check Also

C language tutorial in telugu free download Part 32

c language tutorial in telugu free download getch in c getch in c language: getch …

Leave a Reply

Your email address will not be published. Required fields are marked *

STATE BANK OF HYDERABAD, ***NAME:Hafiz SD, BRANCH:JALLARAM, ACCOUNT.NO:62041435239, IFSC CODE:SBHY0020609,****, ANDRA BANK*** NAME:SYED HAFEEZ BABA, BRANCH:8INCLINE COLONY, ACCOUNT.NO:116710100037533****SBI****NAME:SYED HAFEEZ BABA,ACCOUNT NO:35321924009,IFSC CODE:SBIN0013338,BRANCH:GODAVARIKHANI.,...