Reply to topic  [ 7 posts ] 
C++ 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Post C++
This is more of a query than an actual question.

Just started learning C++ and I've read that the .cpp file(s) has to be compiled for the specific OS and CPU etc... in order to run.

i.e. if I compile a program and send you the resultant exe file it may not work on your Windows PC. (Is that right?)

If so, how do games using OpenGL (based on C++) get around this? They need to produce a game that will run on any configuration of OS version and CPU.

i.e. if I was to write a program in C++ and try to sell it (hypothetically) how would I create an exe that can run on any Windows machine?

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Fri Jan 14, 2011 1:14 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
This is more of a query than an actual question.

Just started learning C++ and I've read that the .cpp file(s) has to be compiled for the specific OS and CPU etc... in order to run.

i.e. if I compile a program and send you the resultant exe file it may not work on your Windows PC. (Is that right?)


Sort of

You need any dependent dlls on the machine
Fogmeister wrote:
If so, how do games using OpenGL (based on C++) get around this? They need to produce a game that will run on any configuration of OS version and CPU.

i.e. if I was to write a program in C++ and try to sell it (hypothetically) how would I create an exe that can run on any Windows machine?

You can do, you just need to package it with all the files it needs to run if the user doesn't have them

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Fri Jan 14, 2011 1:44 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
You need to re-target the code at compile time, to the specific architecture.

That usually means compiler switches to change the includes and branch compile different classes or methods in classes, which are architecture specific.

The core code will be the same, cross platform, but the UI and IO routines will generally need to be re-written for each platform (unless it is a plain command line routine) or you use a transportable toolkit, like qt.

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Sat Jan 15, 2011 11:24 am
Profile ICQ
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
If anyone needs a programme that can test if a piece of text is palindromic then give me a call :D

Slowly but surely working through the text book!

:cool:

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon Jan 24, 2011 11:20 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
If anyone needs a programme that can test if a piece of text is palindromic then give me a call :D

Slowly but surely working through the text book!

:cool:

Code:
for(int i = 0; i < (int)(stringCheck.Length/2) ; i++ )
{
    if( stringCheck[i] != stringcheck[stringCheck.Length - i] )
          return false;
}

return true;


something like that? (It might be a bit off, it's early and I just wrote that in the reply box direct)

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Tue Jan 25, 2011 8:06 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
finlay666 wrote:
Fogmeister wrote:
If anyone needs a programme that can test if a piece of text is palindromic then give me a call :D

Slowly but surely working through the text book!

:cool:

Code:
for(int i = 0; i < (int)(stringCheck.Length/2) ; i++ )
{
    if( stringCheck[i] != stringcheck[stringCheck.Length - i] )
          return false;
}

return true;


something like that? (It might be a bit off, it's early and I just wrote that in the reply box direct)

A bit more than that. It has to standardise the text etc before hand...

i.e. "eve" would return true in your program but "Eve" wouldn't. Also it's teaching stuff like algorithms and functions and locales so they've put all those in there too.

Another one to test... "A man, a plan, a canal. Panama!" is also a palindrome but not according to your program :D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Tue Jan 25, 2011 10:18 am
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Yeah I just did it on a word, and I had just gotten up lol

Simple-ish way in C#....
Code:
Regex expression = new Regex("[^a-z]");

           sometext = settext.ToLower();
            string a = expression.Replace(sometext , string.Empty);
            string b = expression.Replace(sometext , string.Empty);

            b.Reverse();
            if (b.Equals(a))
            {
                // WIN
            }

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Jan 26, 2011 12:32 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.