Thread: Pretty Dumb Question

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Pretty Dumb Question

    Ok, can anybody tell me how I can read this combination of text and variables into a character array?
    Code:
    	"Roster Starts at: ";
    	date;
    	"\n\nRostered Shifts...\n\n";
    	"MONDAY :: ";
    	mo_one;
    	" -- ";
    	mo_two;
    	"\n\nTUESDAY :: ";
    	tu_one;
    	" -- ";
    	tu_two;
    	"\n\nWEDNESDAY :: ";
    	we_one;
    	" -- ";
    	we_two;
    	"\n\nTHURSDAY :: ";
    	th_one;
    	" -- ";
    	th_two;
    	"\n\nFRIDAY :: ";
    	fr_one;
    	" -- ";
    	fr_two;
    	"\n\nSATURDAY :: ";
    	sa_one;
    	" -- ";
    	sa_two;
    	"\n\nSUNDAY :: ";
    	su_one;
    	" -- ";
    	su_two;
    Thanks
    Last edited by face_master; 07-30-2002 at 06:32 AM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    95
    An array can not be of mxed types. You can use an array of pointers.

    I'm not sure about this one but I would set up a structure the create an array of structures.

  3. #3
    Unregistered
    Guest
    lot's of assumptions but maybe something like this?:

    char comma[] = ",";
    char buffer[500];

    strcpy(buffer, "Roster starts at:")
    strcat(buffer, comma);
    strcat(buffer, date);
    strcat(buffer, comma);
    strcat(buffer, "Monday :: ");
    //etc.


    assumption #1: all variables are strings
    assumption #2: you want just a unidimensional array of char and not an array of strings.
    assumption #3: no other commas are allowed in the input except as delineators

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    sprintf( buffer, "The %i way to do that %.2f%% of the time would be %s", 1, 100.00, "this...\n");
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Yes, I think i'll just use strcpy() to add all the string onto the buffer. Thanks for helping...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dumb Question for C Newbie
    By JohnW in forum C Programming
    Replies: 3
    Last Post: 08-13-2008, 01:09 PM
  2. dumb question
    By travis999 in forum C Programming
    Replies: 3
    Last Post: 10-26-2007, 12:57 AM
  3. Dumb question time - Winsock & accept()
    By jdinger in forum Networking/Device Communication
    Replies: 5
    Last Post: 06-11-2005, 01:08 AM
  4. Dumb question
    By fantim in forum C Programming
    Replies: 1
    Last Post: 03-03-2005, 01:48 AM
  5. another dumb question - loop not working?
    By Captain Penguin in forum C++ Programming
    Replies: 8
    Last Post: 10-06-2002, 10:15 PM