LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   checking for null values from config file? (https://www.linuxquestions.org/questions/programming-9/checking-for-null-values-from-config-file-372279/)

zerointeger 10-12-2005 10:22 AM

checking for null values from config file?
 
Newb question I know.

How can I ensure values from a config file are not null or a non \0 char?

Here is what I have:

static int _check_config()
{
udataptr myUser = &localUser;
myConfigPtr myConfig = &localConfig;

if( ( myConfig->var1 != '\0' ) && ( myConfig->var2 != '\0' )
&& ( myConfig->var3 != '\0' ) && ( myConfig->var4 != '\0' )
&& ( myConfig->var5 != '\0' ) ) {
return 0;
} else {
return 1;
}
}

Just assume they are all strings from stdin. Any help is appreciated.

zerointeger 10-12-2005 11:29 AM

not one response, strlen()

example;

Code:

if( ( strlen( myConfig->var1 ) -1 ) != '\0' ) {
  // do the processing
} else {
  // error string was null
}



All times are GMT -5. The time now is 06:08 AM.