Quote:
Originally Posted by back from retirement
It's probably too late....yet I am posting my strcpy....
Code:
#include<stdio.h>
#include<conio.h>
#define m 100
void my_strcpy(char a[m], char b[m])
{
int i;
for(i=0;i<m;i++)
{
b[i]=a[i];
}
return;
}
void main()
{
char a[m], b[m];
printf("Enter your array\t");
scanf("%s", a);
my_strcpy(a,b);
printf("Copied string\t%s", b);
getch();
}
Please report for any inconvenience......cheers.....
----------------------
@ r k @
hi i also need to solve this c++ question in my tutorial.
lets say instead i have to declare the my_strcopy before my int main(void) 's body. then i will declare my array as above in the main's body. after which i pass 2 arrays into my_strcopy to copy them.. after my mainbody, i would then define my function.
the question is... how do i declare the prototype before my main body?
i still have a question on fflush(stdin)
lets say i have
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a;
char name;
printf("enter a number\n");
scanf("%d",&a);
fflush(stdin);
printf("enter a name:\n");
scanf("%s",&name);
printf("a is %d, name is %c\n",a,name);
system("pause");
return 0;
}
what is the idea of fflush(stdin)? i know it is something related to inputbuffer and inputstream but i cant figure it out... and another thing to note.. how do i store a string of letters into "name"?