[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

void pushItem or int pushItem checking err codes

Posted on 2009-02-19
3
Medium Priority
?
182 Views
Last Modified: 2012-05-06
hi,

is it usually to check whether the push operation in the stack is successful.

Something like this

if(pushItem()==SUCCESSFUL)
;
else
print somethng....

usually, i notice, it is void pushItem instead of int pushItem...

which is the usual way. thanks a million.
0
Comment
Question by:zizi21
3 Comments
 
LVL 10

Assisted Solution

by:peetm
peetm earned 800 total points
ID: 23680102
I would say that if pushItem() may fail [and it probably can!], then, you should have some mechanism for detecting that.

Of course, this could be implemented within pushItem(), but what would that mean - 'abort' most likely.

If you were using C++ you could use exceptions - functions that return indications of success/failure have a way of being called like subroutines, i.e., having their result ignored.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 1200 total points
ID: 23680106
Depends. If your stack/queue has a limited size, you might want to return an error in case the stack is full, and the user tries to push a value on it.
0
 

Author Comment

by:zizi21
ID: 23680163
thanks a million...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question