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 |
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
How can I handle floating-point exceptions gracefully?
Define function ?Explain about arguments?
2 Answers Geometric Software, Infosys,
write a c program to remove all the duplicate characters in a string and replace with single character? ex:-input- AAABBBCCC output- ABC
please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }
f() { int a=2; f1(a++); } f1(int c) { printf("%d", c); } c=?
Explain how are 16- and 32-bit numbers stored?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
What do you mean by c what are the main characteristics of c language?
What are 'near' and 'far' pointers?
What is a char c?
How to run c Program without using IDE of c. means if program made in notepad.then how to compile by command prompt.