Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > perror question

Reply
Thread Tools

perror question

 
 
Clunixchit
Guest
Posts: n/a
 
      06-18-2005
Im writing a program in which i have to perform several mallocs

in order to simply my code i have used
void e_malloc(){
perror("malloc");
_exit(EXIT_FAILURE);
}

if ( !(phrase.T = malloc ( sizeof *(phrase.T)
)))
e_malloc();
instead of
[code:1:c9ebbe2331]if ( !(phrase.T = malloc ( sizeof
*(phrase.T) ))) {
perror("malloc");
_exit(EXIT_FAILURE);
}[/code:1:c9ebbe2331]
my question is, does perror wld still contain the errno message if the
malloc fails

 
Reply With Quote
 
 
 
 
SM Ryan
Guest
Posts: n/a
 
      06-19-2005
lid (Clunixchit) wrote:

# my question is, does perror wld still contain the errno message if the
# malloc fails

errno is a global variable (or looks like a global variable). If set by
malloc it will have the same value in all other functions that reference
it until set to a new value. It won't be changed by simply calling another
function.

perror() references the current value of errno.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Who's leading this mob?
 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting perror Guillaume Dargaud C Programming 12 08-08-2007 09:05 PM
Struts Problem <!-- PError 500: Missing message for key button.submit nanda.rudraraju@gmail.com Java 0 04-07-2006 02:34 PM
cout and perror puzzlecracker C++ 3 10-22-2005 11:56 PM
in what circustances perror would cause core dump? Martin C Programming 7 12-09-2004 08:48 PM
When to use "perror" and "fprintf" L. Westmeier C Programming 6 05-13-2004 07:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57