how to copy a string without using c function
Answers were Sorted based on User's Feedback
Answer / valli
sorry
after for loop it is not
s[i]=s2[i]
but
correct one is
s2[i]=s[i];
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / vignesh1988i
#include<stdio.h>
#include<conio.h>
void str_cpy(char *,char *);
void main()
{
char a[20],b[20];
printf("enter the string to be copied:");
gets(b);
str_cpy(a,b);
puts(a);
getch();
}
void str_cpy(char *str,char *str1)
{
if(str1!='\0')
{
*str=*str1;
str_cpy(++str,++str1);
}
str='\0';
}
thank u
Is This Answer Correct ? | 8 Yes | 8 No |
Answer / ankitecian
int main(int argc, char *argv[])
{
char _output[200];
memset(_output,'\0',200);
if(argc < 2)
{
printf("Usage: <%s> <String -1>\n",argv[0]);
return -1;
}
StrCpy(_output,argv[1]);
printf("The Final String is::: \n[%s]\n",_output);
return 0;
}
int StrCpy(char *_output, const char *_input1)
{
int _cntr1 = 0;
while(*(_input1 + _cntr1) != NULL)
{
*(_output + _cntr1) = *(_input1 + _cntr1);
_cntr1++;
}
return 0;
}
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / 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 |
Answer / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
char a[40],b[40];
int i=0,c,j;
printf("\nEnter the first string ");
while((a[i++]=getchar())!='\n');
for(c=0;c<i;c++)
{
b[c] = a[c];
}
for(j=0;j<i;j++)
{
printf("%c",b[j]);
}
getch();
}
Is This Answer Correct ? | 3 Yes | 6 No |
find out largest elemant of diagonalmatrix
What is this infamous null pointer, anyway?
what is the difference between structure and union?
Why should I prototype a function?
Explain what is the advantage of a random access file?
Please list all the unary and binary operators in C.
sqrt(x+sqrt(x+sqrt(x+sqrt(x))))=2; Find the value of x?
though sbi was nationalized why its not comes under nationalized banks and its comes under publicsector banks
3 Answers State Bank Of India SBI,
print the pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 if n=5
code for selection sort?
write a program that print itself even if the source file is deleted?
What does the message "warning: macro replacement within a string literal" mean?