multiline variable

This is a discussion on multiline variable within the C++ Programming forums, part of the General Programming Boards category; yes i did searhc the posts and looked on the internet. but is there a c++ varible that can hold ...

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    multiline variable

    yes i did searhc the posts and looked on the internet. but is there a c++ varible that can hold data that is more than one line?
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    What do you mean by data which is on more than one line?

    Do you mean a structure, like:

    TPoint p;
    p.x = 20;
    p.y = 20;

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    ok i am making a game.... i need this to be a varible

    cout << "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&& *"<<endl;
    cout << "& & **"<<endl;
    cout << "& 1. Resume Game & ****"<<endl;
    cout << "& & **** *******"<<endl;
    cout << "& & * * *********"<<endl;
    cout << "& 2. Save Game & * * *************"<<endl;
    cout << "& & **** *****************"<<endl;
    cout << "& & ** ##############"<<endl;
    cout << "& 3. View Status & ** #### ## ####"<<endl;
    cout << "& & ** ##### ## #####"<<endl;
    cout << "& & ** ##### ## #####"<<endl;
    cout << "& 4. View Map & ** ################"<<endl;
    cout << "& & ** ##############"<<endl;
    cout << "& & ** ############"<<endl;
    cout << "& 5. Go to Main Screen & ** %%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "& & ** %%%%%%%%%%%%%%%%%%%%%"<<endl;
    cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ** %%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
    and i have 4 other like it with different ascii arts next to the menu, btu it takes 17 lines, i need each menu make to be a varible
    ----
    edit
    ----
    the thing is kinda deformed, if u compile it it might come out irght its supposed to be a menu (just ext) next to a character.
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  4. #4
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    on ur structure

    TPoint p;
    p.x = 20;
    p.y = 20;

    could i do like

    p.a = first line of menu
    p.b = second line of menu

    and so fourth and the varible would be p?
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Are you sure you don't want to make it a function?

  6. #6
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    uh i dont know about functions yet

    would my way work i just asked about
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  7. #7
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107
    Data that is more than one line? All strings can be variables. And so can this:
    char something[34]="First line\nSecond line\nThird line";
    I am not using Dev-C++.
    #!/usr/bin/env python
    import sys;file=open(sys.argv[0]);print file.read();file.close()

  8. #8
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    oh those are functions, i know abotu that crap, i wasnt htinking

    char something[17]="First line\n, Second line\n, Third line";

    isnt it like that tho?
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  9. #9
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > oh those are functions, i know abotu that crap, i wasnt htinking

    No, those are strings (well, char arrays, whatever)

    > isnt it like that tho?

    No - you don't enough space.

  10. #10
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    wel here was the resualt
    Code:
    char mage[17] ="&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                   *\n&                             &                    **\n&  1. Resume Game             &                     ****\n&                             &       ****          *******\n&                             &      *    *       *********\n&  2. Save Game               &      *    *     *************\n&                             &       ****     *****************\n&                             &        **        ##############\n&  3. View Status             &        **       ####   ##   ####\n&                             &        **      #####   ##   #####\n&                             &        **      #####   ##   #####\n&  4. View Map                &        **       ################\n&                             &        **        ##############\n&                             &        **         ############\n&  5. Go to Main Screen       &        **      %%%%%%%%%%%%%%%%%%%\n&                             &        **     %%%%%%%%%%%%%%%%%%%%%\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&        **   %%%%%%%%%%%%%%%%%%%%%%%%\n";
    i cant use the char varible or any other arible i could htink of or find, wut vairble type should i use

    note u gotta scroll to the right
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  11. #11
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Wow... no.

    First - your char array only has space for 17 characters - you have a few more than that.

    Second - use a function. Seriously - read about it. Learn about them - you can't write anything of decent length without functions.

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    You can solve both the length problem (by letting the compiler count the chars for you), and the formatting problem like so
    Code:
    char mage[] = "&&&&&&&&&&&-MENU-&&&&&&&&&&&&&&                   *\n"
                  "&                             &                   *\n"
                  "&  1. Resume Game             &                ****\n"
                  "&                             &";

  13. #13
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    thanks salem
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  14. #14
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    what would ever be the point in counting characters fi the ocmpiler can count for you?
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  15. #15
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Because sometimes you can't initialize the char array when it's created, and user input is needed.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about printing a variable???
    By Hoser83 in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2006, 12:57 PM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  3. static class variable vs. global variable
    By nadamson6 in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2005, 03:31 PM
  4. write Variable and open Variable and get Information
    By cyberbjorn in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 01:30 AM
  5. Replies: 8
    Last Post: 04-22-2002, 10:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21