GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 28-Oct-2009, 03:43
saqib_ saqib_ is offline
New Member
 
Join Date: Oct 2009
Posts: 12
saqib_ has a little shameless behaviour in the past

Re: 1 loop structure to find the sum of odd and even integers


I use the following code,

CPP / C++ / C Code:
/**/

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{

// ---> Stuff goes here

system("pause");
return 0;
}
Last edited by admin : 29-Oct-2009 at 03:35. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #12  
Old 28-Oct-2009, 04:51
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 226
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: 1 loop structure to find the sum of odd and even integers


Quote:
Originally Posted by saqib_
I use the following code,

CPP / C++ / C Code:
/**/

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    // ---> Stuff goes here

    system("pause");
    return 0;
}

Any "system" call is, by its very nature, going to be platform specific and the "pause" executable typically is not available on Unix or Mac, rather, only DOS and Windows.

You need to read the GUIDELINES.


MxB
  #13  
Old 28-Oct-2009, 06:21
saqib_ saqib_ is offline
New Member
 
Join Date: Oct 2009
Posts: 12
saqib_ has a little shameless behaviour in the past

Re: 1 loop structure to find the sum of odd and even integers


Does it mean that same c++ code can not be run on different platforms? A programmer has to keep in mind the operating system first and then write the code.
  #14  
Old 28-Oct-2009, 06:38
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 226
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: 1 loop structure to find the sum of odd and even integers


Quote:
Originally Posted by saqib_
Does it mean that same c++ code can not be run on different platforms?

...in many cases one can easily write C++ code that does not perform as intended (desired). A good example is code that expects data to be in little endian format when executing on a big endian machine or vice versa. Another is when using calls that invoke operating system specific "capabilites" such as the standard C library "system" call. You are passing in the name of an "executable" (a command) in the form of a const char* variable. It is possible for the C (or C++ in this case) code to compile without error or warning if I write the following:

CPP / C++ / C Code:
int result = system("do_floop_bloak_neffer_yarndote");

...I'm guessing that there are not going to be many "systems" out there that offer the do_floop_bloak_neffer_yarndote command.

In your case, the "pause" command is available because your particular system exposes it to the command line.


Quote:
Originally Posted by saqib_
A programmer has to keep in mind the operating system first and then write the code.

...or at least avoid any platform-specific code.


MxB
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:53.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.