LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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
 
LinkBack Search this Thread
Old 01-30-2004, 01:35 PM   #1
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
Gimp Tool Kit gchar Widget comparison...


i'm trying to see if a variable is NULL or if there is nothing assigned to it and if so continue with plan. however its no working properly:

fstream File;
const gchar *filename = gtk_entry_get_text(GTK_ENTRY(name));
/* if filename is empty then it supposed to out to the screen
that you need to enter a name in the name field.
*/
if(filename != NULL) // i've also tried(f != "")
{
if(pwd == confirm_pwd);
{
File.open(filename,ios::out);
File.close();
}
}else{printf("You must enter a name.");}

it doesnt do the comparison properly and goes through with creating a blank file name. is there anyway to check the contents to see if its empty or not?
 
Old 01-30-2004, 04:25 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 39,853

Rep: Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121
just try...

if(filename)
{
...
}

A null value will fail... think it works under C....

Also better to use strcmp() or a similar function for string tests, == is designed for numerical tests
 
Old 01-30-2004, 04:30 PM   #3
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Original Poster
Rep: Reputation: 30
i got it to work. i was using boolean values instead of just 0 for strcmp()
this website is VERY helpfull:

http://www.phim.unibe.ch/comp_doc/c_...ter_index.html
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help installing FWTK (Firewall tool kit) cynthia_thomas Linux - Networking 1 11-08-2005 06:31 AM
Help tool kit in linux geethu Linux - Software 1 08-16-2005 01:05 PM
Linux Trace Tool Kit version 0.9.6pre2 judy Linux - Software 0 02-20-2004 06:58 PM
GUI test tool to perform widget functions via a text file liguorir Linux - Software 0 01-05-2004 02:30 PM
TV Tool Kit suriyamohan Programming 2 03-21-2003 09:25 PM


All times are GMT -5. The time now is 04:40 AM.

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
Open Source Consulting | Domain Registration