Thread: Variables.

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    15

    Variables.

    what Variables r there?
    i know what is int and float.
    but can i type a full sentences as a Variables?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >i know what is int and float.
    Those are types. Variables are whatever you want as long as the name isn't a reserved word.

    >but can i type a full sentences as a Variables?
    You can, but you need to get creative in separating the words of the sentence:
    Code:
    double some_long_variable_name_that_represents_a_double;
    My best code is written with the delete key.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    TYPE - MINIMUM SIZE (BYTES)
    char - 1
    unsigned char - 1
    int - 2
    unsigned int - 2
    short - 2
    unsigned short - 2
    long - 4
    unsigned long - 4

    float - 4
    double - 8

    but can i type a full sentences as a Variables?
    Do you mean, "Can a variable hold a sentence?" No. A single variable can only hold a single character. You need an array of characters to hold a word or sentence. See the array and string tutorials. C++ also has a string class which can sometimes be used more like a single variable.

    in general programming terminology, string means "a string of characters". In C++, a character array is often called a c-style string to differentiate it from a C++ string class object.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  3. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  4. Replies: 6
    Last Post: 01-02-2004, 01:01 PM
  5. functions to return 2 variables?
    By tim in forum C Programming
    Replies: 5
    Last Post: 02-18-2002, 02:39 PM