hi.
i have problem with following code:
when i give address directly it works correct but when i get address from command line, it does n't work.
int main(int argc, char** argv)
{
int size;
int fd,fd2;
char buf[10000],buf2[10000],FileAdd[10000];
size = read(fd2,buf2,10000);
//char *FileAdd = malloc(size);
strcpy(FileAdd,buf2);
if ((fd= open(FileAdd, O_RDONLY)) < 0)
{
perror("unable to open.");
exit(1);
}
read(fd, buf, 10000);
puts(buf);
int filedesc = open("writer.txt", O_WRONLY | O_APPEND);
if (filedesc < 0)
{
return -1;
}
if (write(filedesc, buf, strlen(buf)) != strlen(buf)) {
write(2, buf, strlen(buf));
return -1;
}
return 0;
}