how to copy a string without using c function

Answer Posted / valli

main()
{
char s[20],s2[20];
printf("enter the string");
scanf(" %[^\n]",s);
for(i=0;s[i];i++)
s[i]=s2[i];
s2[i]='\0';
printf("%s",s2);
}

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the significance of scope resolution operator?

1108


What is the symbol indicated the c-preprocessor?

930


What is the equivalent code of the following statement in WHILE LOOP format?

1076


Explain heap and queue.

790


write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

2639


Explain how do you sort filenames in a directory?

798


write a c program to calculate sum of digits till it reduces to a single digit using recursion

2974


Is main is user defined function?

845


What are the advantages of c preprocessor?

969


Why is struct padding needed?

807


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1724


What is extern c used for?

755


What is integer constants?

789


What is double pointer?

757


What is malloc calloc and realloc in c?

909