P
priyanka
Hi there,
I need to copy the first 5 characters stored in a buffer into another
buffer one character at a time. I tried doiing it as under but I got
segmentation errors:
#include<stdio.h>
#define LENGTH 5
char * kernel_buf;
char * user_buf = "Priya is confused\n";
int main(){
int i;
char ch;
printf("user_buf:%s",user_buf);
for(i = 0; i < LENGTH; i++){
*kernel_buf = *(user_buf++);
printf("%c\n",*kernel_buf);
}
return 1;
}
The message I get is:
user_bufriya is confused
Segmentation fault
If anyone could help me figure out where I am wrong it would be very
helpful.
Thank you,
Priya
I need to copy the first 5 characters stored in a buffer into another
buffer one character at a time. I tried doiing it as under but I got
segmentation errors:
#include<stdio.h>
#define LENGTH 5
char * kernel_buf;
char * user_buf = "Priya is confused\n";
int main(){
int i;
char ch;
printf("user_buf:%s",user_buf);
for(i = 0; i < LENGTH; i++){
*kernel_buf = *(user_buf++);
printf("%c\n",*kernel_buf);
}
return 1;
}
The message I get is:
user_bufriya is confused
Segmentation fault
If anyone could help me figure out where I am wrong it would be very
helpful.
Thank you,
Priya