Sunday, August 2, 2009

What is the use of ((const int i=5))?... Can u tell me more abt strings?

im really get confused abt something....In C++, What is the use of ((const int i=5))..I need to know the use const??!


Can u explain more in how to use strings? and when??

What is the use of ((const int i=5))?... Can u tell me more abt strings?
const stands for constant. so the value of the variable declared as const remains constant throughout the program i.e. 5 here.





in c++, there is separate string class. u can use the c strings.





so c string is char c[] = "my string";





c++ string is String c = "my string";
Reply:I know little about Programming %26amp; Design...... though I loved computers very much, I still chose Bussiness Administration as my major following my father's advice.
Reply:const is short for constant. A constant integer cannot be modified once it is defined. In this case, i will always be 5 throughout the program.
Reply:const int i=5 menace i is 5 thought the program until you can not modified it.


In C++ there is not any string data type. So you can use a string by declaring character array. like


char s[20];


gets(s);


put(s);


with the help of this you can declare a string, input it %26amp; and print it.


If you want to seprate each character from string then you use for loop


like


for(i=0;s[i]!='\0';i++)


putchar(s[i]);





Other wise you can use string function directly.


I think that is suffisient for you. If any other dificulty then ask again.


No comments:

Post a Comment