Question about Arrays

Ok this is probably pretty easy but I'm stuck.

My program reads the contents of a txt file and stores the string into a char array called buff. The contents of the text file is a string of a txt file name. So basically buff has this value "file.txt\0". The last part is the null character. I want to use buff in an open system call like so: open( buff, O_RDWR ), and the file, "file.txt" will open. But you can obviously see the problem, open() is trying to open "file.txt\0" instead. How can I modify buff so that it isn't looking for the filename with an appended null char on the end? Thanks for reading this.

This question does not make sense. The very definition of a string is a series of characters terminated by a null. If you remove that null, the string is extended until a null is found. This will cause the open call to think that you are trying to open a file with a very lengthy name.

It may help to post the error message you
are getting. Try...

...
if(open(buff, O_RDWR) < 0)
{
perror(buff);
exit(1);
}

...then post what "perror" generates.

My apologies...

The 1st code is just a quick example.
It was not fully written. Here's the "correct"
version...

...
if((fd=open(buff, O_RDWR)) < 0)
{
perror(buff);
exit(1);
}
...

...I didn't want to confuse you further.