7 Replies - 1713 Views - Last Post: 08 April 2009 - 09:41 AM Rate Topic: -----

#1 tomfable   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Proccess Terminated (using Code::Blocks)

Post icon  Posted 07 April 2009 - 12:47 PM

Hello everyone. I started learning C++ not long ago and need help. I made a little project and here is the code:

#include <iostream>

using namespace std;

int main()
{
cout << "4356547548782215423987\n";

for( int i = 65000; i < 10; i++ );
}

---------------------------------------------------------------------------------------------------------------------------------------
The final result after compiling:
Compiling: main.cpp
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
---------------------------------------------------------------------------------------------------------------------------------------
What can I do and what's wrong? I've been trying to figure out the porblem... but failed.

Is This A Good Question/Topic? 0
  • +

Replies To: Proccess Terminated (using Code::Blocks)

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Proccess Terminated (using Code::Blocks)

Posted 07 April 2009 - 12:49 PM

Aside from missing a return statement and some sort of purpose with your code, nothing is wrong. Your for loop never executes, but that is irrelevant as there's nothing in its body.
Was This Post Helpful? 0
  • +
  • -

#3 chris772   User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 190
  • Joined: 13-March 09

Re: Proccess Terminated (using Code::Blocks)

Posted 07 April 2009 - 03:53 PM

Notice, your loop is a for with an i value of 65,000. The loop will run only if i is less than 10, which will be impossible with its initialized value. Usually you set a for loop with an i value of 0, then configure the less than to however many times you want it to run.

for example:
for (int i = 0; i<10; i++)


would run 10 times.

for (int i = 0; i<3; i++)


would run 3 times.
Was This Post Helpful? 0
  • +
  • -

#4 tomfable   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: Proccess Terminated (using Code::Blocks)

Posted 08 April 2009 - 04:39 AM

View Postchris772, on 7 Apr, 2009 - 02:53 PM, said:

Notice, your loop is a for with an i value of 65,000. The loop will run only if i is less than 10, which will be impossible with its initialized value. Usually you set a for loop with an i value of 0, then configure the less than to however many times you want it to run.

for example:
for (int i = 0; i<10; i++)


would run 10 times.

for (int i = 0; i<3; i++)


would run 3 times.


I tried, doesn't work!

View PostKYA, on 7 Apr, 2009 - 11:49 AM, said:

Aside from missing a return statement and some sort of purpose with your code, nothing is wrong. Your for loop never executes, but that is irrelevant as there's nothing in its body.

Doesn't help...
Was This Post Helpful? 0
  • +
  • -

#5 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1433
  • View blog
  • Posts: 11,006
  • Joined: 06-February 08

Re: Proccess Terminated (using Code::Blocks)

Posted 08 April 2009 - 04:46 AM

Sounds like you're pressing the wrong button to compile - you're pressing "compile" instead of "compile and run."

Try hitting F9. :)


edit
Just saw your question in the thanks. :)

There's actually no problem with compiling whatsoever. Basically, by just clicking "compile" it will compile it, then terminate the process before launching it.

If you "compile and run" it, it will compile it then run it.

Try just using the compile button, then look in the bin\debug or bin\release (depending on your configuration) (my guess is it'll be in debug, the default) and you'll still see the exe there. :)

This post has been edited by gabehabe: 08 April 2009 - 04:58 AM

Was This Post Helpful? 1
  • +
  • -

#6 tomfable   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: Proccess Terminated (using Code::Blocks)

Posted 08 April 2009 - 05:39 AM

View Postgabehabe, on 8 Apr, 2009 - 03:46 AM, said:

Sounds like you're pressing the wrong button to compile - you're pressing "compile" instead of "compile and run."

Try hitting F9. :)


edit
Just saw your question in the thanks. :)

There's actually no problem with compiling whatsoever. Basically, by just clicking "compile" it will compile it, then terminate the process before launching it.

If you "compile and run" it, it will compile it then run it.

Try just using the compile button, then look in the bin\debug or bin\release (depending on your configuration) (my guess is it'll be in debug, the default) and you'll still see the exe there. :)

I got a one more question. I press F9 and it runs it but it doesn't loop... what's wrong? (I want it to look like a matrix thing and it just writes the numbers once and done...
Was This Post Helpful? 0
  • +
  • -

#7 janotte   User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Proccess Terminated (using Code::Blocks)

Posted 08 April 2009 - 05:54 AM

View Posttomfable, on 8 Apr, 2009 - 04:39 AM, said:

I got a one more question. I press F9 and it runs it but it doesn't loop... what's wrong? (I want it to look like a matrix thing and it just writes the numbers once and done...


Have you changed the code since your first posting?

If you have then show us the new code.

If you are still using the old code then you will have to put your "cout" statement inside a loop if you want it to be done more than once.

Do you know how to put code inside a loop?

for( int i = 0; i < 200; i++ ) {
	cout << "hello world" << endl;
}


This post has been edited by janotte: 08 April 2009 - 05:54 AM

Was This Post Helpful? 1
  • +
  • -

#8 tomfable   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: Proccess Terminated (using Code::Blocks)

Posted 08 April 2009 - 09:41 AM

Thank you all, you all helped me, everything's done correctly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1