I am having a problem with the opendir
function in C. Here is the code:
Declaration of rvm
:
rvm_t func()
{
rvmBlock=(rvm_t)malloc(sizeof(rvm_t));
return rvmBlock;
}
rvm_t rvm;
rvm=func();
printf("rvm->backingStore=%s\n", rvm->backingStore);
if( (dir = opendir(rvm->backingStore)) !=NULL )
{
printf("rvm->backingStore inside if=%s\n", rvm->backingStore);
}
The output i am getting for this is:
rvm->backingStore=rvm_segments/
rvm->backingStore inside if=rvm_segments!?
"!?"
are some garbage characters that are appearing for some reason.
Can someone explain what is going wrong.
Here is the rvm structure:
struct rvm_info
{
char backingStore[20];
struct memSeg * memSegs[20];
long int storage_size;
int memSeg_count;
FILE * log_fd;
};
typedef struct rvm_info* rvm_t;