mastersibn
12-14-2000, 11:02 PM
Right. The snippet is actually quite small and sometimes I have related problems that aren't this one. What I need to know is why sometimes I can't set variables inside a function. Function in question:
int main( void )
{
/* Get the home dir. */
struct passwd *pw_entry;
pw_entry = getpwuid( geteuid( ) );
char *BaseDir = EvalBaseDir( pw_entry->pw_dir );
return( 0 );
}
char *EvalBaseDir( char *PwDir )
{
char *BaseDir = strcat( PwDir, "/.gtkak" );
return( BaseDir );
}
Now what makes this annoying is that if I remove the char BaseDir..., and replace it with printf( "%s \n", EvalBaseDir( pw_entry->pw_dir ); then everything works flawlessly.
Gcc is complaining that I'm trying to create this string, but I can't find any other viable ways to do it. Why can't I creat char *BaseDir?
Like I said, sometimes I have problems assigning variables (global vars, for instance, -never- work for me). I'd really like to know why this always fails.
I'm only using the -Wall switch to compile...
thx
------------------
grab my gnupg key (http://jove.prohosting.com/~msibn/sibn-p.asc) if you feel so inclined.
cAPS lOCK? wHAT cAPS lOCK?
I cna ytpe 300 wrods pre mniuet!!!
an operating system has not just advantages...
int main( void )
{
/* Get the home dir. */
struct passwd *pw_entry;
pw_entry = getpwuid( geteuid( ) );
char *BaseDir = EvalBaseDir( pw_entry->pw_dir );
return( 0 );
}
char *EvalBaseDir( char *PwDir )
{
char *BaseDir = strcat( PwDir, "/.gtkak" );
return( BaseDir );
}
Now what makes this annoying is that if I remove the char BaseDir..., and replace it with printf( "%s \n", EvalBaseDir( pw_entry->pw_dir ); then everything works flawlessly.
Gcc is complaining that I'm trying to create this string, but I can't find any other viable ways to do it. Why can't I creat char *BaseDir?
Like I said, sometimes I have problems assigning variables (global vars, for instance, -never- work for me). I'd really like to know why this always fails.
I'm only using the -Wall switch to compile...
thx
------------------
grab my gnupg key (http://jove.prohosting.com/~msibn/sibn-p.asc) if you feel so inclined.
cAPS lOCK? wHAT cAPS lOCK?
I cna ytpe 300 wrods pre mniuet!!!
an operating system has not just advantages...