Results 1 to 8 of 8

Thread: c++ question

  1. #1
    Join Date
    Oct 2007
    Location
    USA
    Beans
    354

    Question c++ question

    Hi,

    I tried running this command using g++ thru terminal:

    #include <iostream>
    using namespace std;

    int main(void)
    {
    system("TITLE Calculator");
    system("COLOR 3");

    cout<<9+3<<endl;

    return 0;
    }

    but this error always pops up:

    limac@limac-ubuntu:~$ cd ~/Desktop
    limac@limac-ubuntu:~/Desktop$ g++ -o co co.cpp
    limac@limac-ubuntu:~/Desktop$ ./co
    sh: TITLE: not found
    sh: COLOR: not found
    12
    limac@limac-ubuntu:~/Desktop$

    What can i do about this?

    Thnx
    Think carefully before just copying and pasting the commands your are advised into your terminal and clicking Enter, for more information about which ones not to use see this: http://ubuntuforums.org/announcement.php?f=73

  2. #2
    Join Date
    Dec 2007
    Beans
    11

    Re: c++ question

    AFAI understand you are trying to change the title of your terminal. I dont think you can just type TITLE to do this. gnome-terminal --title=Calculator should do the trick.

  3. #3
    Join Date
    Apr 2007
    Beans
    14,781

    Re: c++ question

    Are you getting this code from somewhere else? They are Windows commands, and won't work in Linux.

  4. #4
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: c++ question

    Not sure what you're trying to accomplish.

    The int system(const char *command) function is used for system commands. This means that any command you pass into that function must be executable on your system's default command interpreter. If you can't run those commands on terminal - in this case you can't - then they won't work.

  5. #5
    Join Date
    Sep 2007
    Beans
    Hidden!

    Re: c++ question

    Quote Originally Posted by limac View Post
    Hi,

    I tried running this command using g++ thru terminal:

    #include <iostream>
    using namespace std;

    int main(void)
    {
    system("TITLE Calculator");
    system("COLOR 3");

    cout<<9+3<<endl;

    return 0;
    }

    but this error always pops up:

    limac@limac-ubuntu:~$ cd ~/Desktop
    limac@limac-ubuntu:~/Desktop$ g++ -o co co.cpp
    limac@limac-ubuntu:~/Desktop$ ./co
    sh: TITLE: not found
    sh: COLOR: not found
    12
    limac@limac-ubuntu:~/Desktop$

    What can i do about this?

    Thnx
    I think this changes the color of terminal if i am not mistaken...and it's a wrong code...
    Last edited by Kadrus; December 6th, 2007 at 06:32 PM.

  6. #6
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: c++ question

    No it doesn't, at least not on any Linux I know. Perhaps on some other OS
    LambdaGrok. | #ubuntu-programming on FreeNode

  7. #7
    Join Date
    Apr 2007
    Beans
    14,781

    Re: c++ question

    Quote Originally Posted by CptPicard View Post
    No it doesn't, at least not on any Linux I know. Perhaps on some other OS
    It is for Windows.

  8. #8
    Join Date
    Oct 2007
    Beans
    115
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: c++ question

    second time second strike?

    --------------------

    OK, for dont be 1 line not contributing more than pointing the second strike...

    Try the commands of the programm you are trying to compile in the terminal (sh, gnome-terminal and related), you will see the same "fail" results instead of what you are triying to do.
    $ TITLE Calculator
    $ COLOR 3
    If you ask what is that "$" is normally used short of "prompt" of sh (or shell)

    in the man I dont remember the page, but for change color codes in console it is something about the escape character then a secuence that "has a meaning" and finally the close indicator.

    Here are some results from google for: linux sh console color code

    http://www.funtoo.org/en/articles/linux/tips/prompt/
    http://www.newlinuxuser.com/linux-console-codes/

    Aside: Searching for the man page, have found this, seem usefull for have nice display? hehehe
    http://www.console-colors.de/index.p...Tools.ColorGCC
    Last edited by tyoc; December 6th, 2007 at 10:29 PM.
    me ||
    Las cosas que no se comparten se pierden. || Todo es lo que aparenta ser hasta que se descubre lo que en realidad es.
    How to become a hacker?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •