Q:

Copy string in C without using strcpy

0

Copy string in C without using strcpy

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>

int main()
{
  int c = 0;
  char s[1000], d[1000] = "What can I say about my programming skills?";

  printf("Before copying, the string: %s\n", d);

  printf("Input a string to copy\n");
  gets(s);

  while (s[c] != '\0') {
    d[c] = s[c];
    c++;
  }

  d[c] = '\0';

  printf("After copying, the string: %s\n", d);

  return 0;
}

Output of the program:

Before copying, the string: What can I say about my programming skills?
Input a string to copy
My programming skills are improving.            
After copying, the string: My programming skills are improving.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now