Thursday, July 9, 2009

C Programming - how do you define a word?

How do you define a long word - such as days of the week? I've tried char, and can't think of anything else to try!


Thanks!

C Programming - how do you define a word?
Your question is not clear enough ! but I think you it should be one of the cases below:





#define SIZE 5





the aim of using define in C is to prevent changing all variables or strings in whole program, so you may define it once and change it once, it will affect to entire program. in this example everywhere you use SIZE in your program it means it's 5 ! (SIZE has to be in written in capital letters).





in case that you want to define a string, you need to write the following code:





char string_name[size];





that size should be replaced by an integer value, that shows the length of string.


2D string is little bit more complex than 1D ... maybe the following example is what you need ;)





char week[7][10]={"Sunday","Monday","Tuesday"...
Reply:Word is a bad word to use, I think you're looking for the word 'string'. Here's a string:





char *mystring = "Thursday";
Reply:typedef enum


{


SUNDAY,


MONDAY,


TUESDAY,


WEDNESDAY,


THURSDAY,


FRIDAY,


SATURDAY,


SUNDAY


} TYPE_WEEKDAY;
Reply:In c you will have to use a character array.





RJ
Reply:#define SUNDAY 1
Reply:a long word in programming is called a String.





in C, however, you would use an array of characters.
Reply:try msdn.com


No comments:

Post a Comment