LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-12-2005, 10:22 AM   #1
zerointeger
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Rep: Reputation: 0
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.
 
Old 10-12-2005, 11:29 AM   #2
zerointeger
LQ Newbie
 
Registered: Oct 2005
Posts: 11

Original Poster
Rep: Reputation: 0
not one response, strlen()

example;

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
null values in bash scripts always true? jdupre Programming 5 09-27-2005 05:22 PM
checking pointer is non-null causes segmentation fault in c++ markhod Programming 10 01-11-2005 11:28 AM
postfix config as null client webwiznz Linux - Networking 0 05-31-2004 07:52 AM
Checking for repeat values techrolla Programming 4 12-09-2003 08:41 PM
dublicate values in file topche Programming 10 07-09-2003 04:44 AM


All times are GMT -5. The time now is 06:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration