473,468 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

perror question

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

Nov 14 '05 #1
1 1930
ch******@gmail-dot-com.no-spam.invalid (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?
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: puzzlecracker | last post by:
In one of my applications, I was mixing perror (cerrno )with cout(iostream) calls and sometimes getting unordered output. The exact context was to print an error condition as well as cause for...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
5
by: L. Westmeier | last post by:
Reading the man pages and some code did not really help me in understanding the difference between - or better when I should use - perror("...") and fprintf(stderr, "...") Any hint or help is...
7
by: Martin | last post by:
My program cored and the following is the call stack in dbx. I would like to know what are the possibilities that when perror is being called, it will core? dbx: warning: cannot get thread count...
10
by: nuke1872 | last post by:
Hello guys, I have a file names network.txt which contains a matrix. I want to read this matrix as store it as an array. I am new to stuff like these...can anybody help me out !! Thanks nuke
10
by: Guillaume Dargaud | last post by:
Hello all, I have some error checking using the function 'perror', which writes messages on stderr. I'd like to send all error messages to a file instead. Is there some way to do this, short of...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.