Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

C program to count the number of characters copied into string

YASH PAL, 31 July 2024

In this tutorial, we are going to write a C program to copy one string into another and count the number of characters copied in C Programming with practical program code and step-by-step full complete explanation.

C program to count the number of characters copied into string

C Program to count the number of characters copied into a string.

 
#include<stdio.h>
#include<conio.h>

void main()
{
    char string1[80], string2[80];
    int i;

    printf("Enter a stringn");
    printf("?");
    scanf("%s",string2);

    for(i=0;string2[i]!='';i++)
        string1[i]=string2[i];

    string1[i]='';

    printf("n");
    printf("%sn",string1);
    printf("Number of characters=%dn",i);
}

Output

Enter a string
? Manchester
Manchester
Number of characters=10

Enter a string
?westminister

Westiminister
Number of characters=11
c coding problems

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programmingoneonone | WordPress Theme by SuperbThemes