question about initializing variables.

This is a discussion on question about initializing variables. within the C++ Programming forums, part of the General Programming Boards category; I try to run my first programs in c++...and i have a question. Why the word "string" leaves it as ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    230

    question about initializing variables.

    I try to run my first programs in c++...and i have a question. Why the word "string" leaves it as it is and the word "int" change it to bold + a colour of compiler choice....?

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(void){
            int age;
    	string name;
    		// ...
    
    return 0;
    }

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,790
    int is a keyword which is most likely why your IDE/editor changes it to a specific color.
    std::string is a type but not a keyword.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    230
    So, there is no problem on "this"...they are both correct as i see them...right?

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,790
    Yes.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    There may be an option/setting somewhere that can control what gets colored/highlighted in your editor/IDE. The Microsoft Visual Studio series of IDEs had a location where you could create a text file with a specific name and put various types in it that would then be colored like all the usual keywords. The file was named usertype.dat and existed (or needed to be created) in the IDEs common7\IDE directory, i.e.:

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE (for Visual Studio 2005)
    C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE (for Visual Studio 2010)

    The point is, if you have some other editor/IDE or one of the above IDEs then you may be able to change how it shows up if you do a little digging.

    BTW, your post title has nothing to do with initialization of variables.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question bout my work
    By SirTalksAlots in forum C Programming
    Replies: 4
    Last Post: 07-18-2010, 03:23 PM
  2. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 10:07 PM
  3. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  4. question about declaring global variables
    By Dag_ in forum C++ Programming
    Replies: 2
    Last Post: 04-27-2005, 06:03 AM
  5. Initializing variables
    By Stryder_SoZ in forum C++ Programming
    Replies: 4
    Last Post: 11-09-2001, 11:19 AM

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