x404.co.uk
http://www.x404.co.uk/forum/

C++
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=12073
Page 1 of 1

Author:  Fogmeister [ Fri Jan 14, 2011 1:14 pm ]
Post subject:  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?

Author:  finlay666 [ Fri Jan 14, 2011 1:44 pm ]
Post subject:  Re: C++

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

Author:  big_D [ Sat Jan 15, 2011 11:24 am ]
Post subject:  Re: C++

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.

Author:  Fogmeister [ Mon Jan 24, 2011 11:20 pm ]
Post subject:  Re: C++

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:

Author:  finlay666 [ Tue Jan 25, 2011 8:06 am ]
Post subject:  Re: C++

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)

Author:  Fogmeister [ Tue Jan 25, 2011 10:18 am ]
Post subject:  Re: C++

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

Author:  finlay666 [ Wed Jan 26, 2011 12:32 am ]
Post subject:  Re: C++

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
            }

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/