how to copy a string without using c function

Answers were Sorted based on User's Feedback



how to copy a string without using c function..

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

how to copy a string without using c function..

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

how to copy a string without using c function..

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

how to copy a string without using c function..

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

how to copy a string without using c function..

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

Post New Answer

More C Interview Questions

How can you increase the size of a statically allocated array?

0 Answers   TISL,


the expression a=30*1000+2768; evalutes to a) 32768 b) -32768 c) 113040 d) 0

1 Answers  


What are the string functions? List some string functions available in c.

0 Answers  


Is c++ based on c?

0 Answers  


a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if

0 Answers  


what is the different between data structure and data type?

1 Answers   Ignou,


write a c program that prints all multiples of 3between 1 and 50.

5 Answers  


How to implement variable argument functions ?

1 Answers   HP,


what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);

10 Answers   IBM,


What is bubble sort technique in c?

0 Answers  


What is a null pointer in c?

0 Answers  


Why is conio.h not required when we save a file as .c and use clrscr() or getch() ?

2 Answers  


Categories