public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* is there any way for exit(1)
@ 2009-03-24 22:43 gfx art
       [not found] ` <C5EECDC2.39513%eljay@adobe.com>
  0 siblings, 1 reply; 3+ messages in thread
From: gfx art @ 2009-03-24 22:43 UTC (permalink / raw)
  To: gcc-help

Hello dear gcc staff

I am trying to use exit(1) to my book exercise to test it
but I can't use it the code will work if I deactivate it

if ( mySize == CAPACITY)
{
     cerr << "No space" << endl;
     exit(1); // I can't use this code when I compile it and I've
included cassert library
}

thank you very much

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: is there any way for exit(1)
       [not found] ` <C5EECDC2.39513%eljay@adobe.com>
@ 2009-03-24 23:26   ` gfx art
  2009-03-24 23:53     ` me22
  0 siblings, 1 reply; 3+ messages in thread
From: gfx art @ 2009-03-24 23:26 UTC (permalink / raw)
  To: John (Eljay) Love-Jensen; +Cc: GCC-help

Thank you very much for your reply.. but I get the same error

List.cpp: In member function ‘void List::erase(int)’:
List.cpp:68: error: ‘exit’ was not declared in this scope

***********************

and this is my member function

#include <iostream>
#include <cassert>

using namespace std;

#include "List.h"

void List::erase(int pos)
{
	if (mySize == 0)
	{
		cerr << "*** List is empty ***\n";
		exit(1);	// I can't use it
	}

	if (pos < 0 || pos >= mySize)
	{
		cerr << "Illegal location to delete -- " << pos
		     << ".  List unchanged. ***\n";
		return;
	}

	// Shift array elements left to close the gap
	for(int i = pos; i < mySize; i++)
		myArray[i] = myArray[i + 1];

	// Decrease list size
	  mySize--;
}



Thank you very much for your time and I know how you help others in
open source world
Ali Mirza..



On Wed, Mar 25, 2009 at 12:49 AM, John (Eljay) Love-Jensen
<eljay@adobe.com> wrote:
> Hi gfx art,
>
> Try this...
>
> #include <cstdlib>
>
> if (mySize == CAPACITY)
> {
>   cerr << "No space" << endl;
>   std::exit(1)
> }
>
> HTH,
> --Eljay
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: is there any way for exit(1)
  2009-03-24 23:26   ` gfx art
@ 2009-03-24 23:53     ` me22
  0 siblings, 0 replies; 3+ messages in thread
From: me22 @ 2009-03-24 23:53 UTC (permalink / raw)
  To: gfx art; +Cc: GCC-help

On Tue, Mar 24, 2009 at 19:25, gfx art <xgrafix@gmail.com> wrote:
>
> List.cpp: In member function ‘void List::erase(int)’:
> List.cpp:68: error: ‘exit’ was not declared in this scope
>
> ***********************
>
> #include <iostream>
> #include <cassert>
>

exit is declared in <cstdlib>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-24 23:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-24 22:43 is there any way for exit(1) gfx art
     [not found] ` <C5EECDC2.39513%eljay@adobe.com>
2009-03-24 23:26   ` gfx art
2009-03-24 23:53     ` me22

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).