I have problems writing into a file.
example: I have a file name abc.txt and i want to write/append a character to the end of the file. However, it is written to the next line.
before write:
abc
after write:
abc
H
what i want:
abcH
here is my code:
Code:
int main ( int argc, char ** argv ) {
char *fileName = argv[1];
int fd;
fd = open(fileName, O_RDWR ,0666);
lseek(fd,0,SEEK_END);
char test[1];
test[0] = 'H';
write(fd,&test,sizeof(test));
return 0;
}
Something wrong with my code?
Thanks in advance!