Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double pop(void)
- {
- if(sp > 0)
- return val[--sp];
- else {
- printf("error: stack emptyn");
- return 0.0;
- }
- }
- int pop(double* outval)
- {
- if(outval == 0) return -1;
- if(sp > 0)
- *outval = val[--sp];
- else {
- printf("error: stack emptyn");
- return -1;
- }
- return 0;
- }
- TRY {
- ...
- THROW(MY_EXCEPTION);
- /* Unreachable */
- } CATCH(MY_EXCEPTION) {
- ...
- } CATCH(OTHER_EXCEPTION) {
- ...
- } FINALLY {
- ...
- }
- int pop(double *dptr)
- {
- if(sp > 0) {
- *dptr = val[--sp];
- return 0;
- } else {
- return 1;
- }
- }
- double pop(int *error)
- {
- if(sp > 0) {
- return val[--sp];
- *error = 0;
- } else {
- *error = 1;
- printf("error: stack emptyn");
- return 0.0;
- }
- int pop(double *d)
- {
- if(sp > 0) {
- *d = val[--sp];
- return 0;
- } else {
- return 1;
- }
- }
- struct stack{
- double* pData;
- uint32 size;
- };
- struct popRC{
- double value;
- uint32 size_before_pop;
- };
- popRC pop(struct stack* pS){
- popRC rc;
- rc.size=pS->size;
- if(rc.size){
- --pS->size;
- rc.value=pS->pData[pS->size];
- }
- return rc;
- }
- popRC rc = pop(&stack);
- if(rc.size_before_pop!=0){
- ....use rc.value
- std::pair<something,bool>
- std::set<...>::insert
- std::map<...>::insert
- enum{FAIL,SUCCESS};
- int empty(struct stack* pS){
- return (pS->size == 0) ? 1 : 0;
- }
- int ok=0;
- do
- {
- /* Do stuff here */
- /* If there is an error */
- break;
- /* If we got to the end without an error */
- ok=1;
- } while(0);
- if (ok == 0)
- {
- printf("Fail.n");
- }
- else
- {
- printf("Ok.n");
- }
Add Comment
Please, Sign In to add comment