Hi guys, I'm trying to copy the output from the for loop to a variable 'temp'
for(int i=1;i<4;i++)
{
printf("%s", 2 * i); //outputs - 246
}
printf("\n");
----------------------------------------------------------
I've tried this to only get 'segmentation fault'
char temp[20];
int a;
for(int i=0;i<10;i++)
{
printf("%d", 20 * i);
memcpy(temp[a], 2 * i, 1);
a++;
}
printf("\n");
---------------------------------------------------------
can anyone help me? Thanks
for(int i=1;i<4;i++)
{
printf("%s", 2 * i); //outputs - 246
}
printf("\n");
----------------------------------------------------------
I've tried this to only get 'segmentation fault'
char temp[20];
int a;
for(int i=0;i<10;i++)
{
printf("%d", 20 * i);
memcpy(temp[a], 2 * i, 1);
a++;
}
printf("\n");
---------------------------------------------------------
can anyone help me? Thanks
Comment