how do i declare a variable so that it can hold a string in c++. for example i want to
create a variabe that can hold the name of countries.
How do i declare a variable so that it can hold a string in c++.?
char a[35];
u can have that
and u can give an array
Char a = new char[566];
Reply:u can declare it either as an array or as an String oblect(string would be ur defined class)
to declare as an array u can use
char country_names[][10];
but better to use a user defined class String and create its object to store strings.write appropriate getters and setters.
i usually do it by keeping such type of classes in a custom .h file and include it in my code
Reply:Use either C style strings or C++ style strings.
C style strings:
http://www.cprogramming.com/tutorial/les...
C++ style strings:
http://www.cprogramming.com/tutorial/str...
Reply:You should define it as character, define
char f;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment