Thread: Help on C Array
View Single Post
  #5 (permalink)  
Old January 30th, 2004, 07:37 AM
ankur_vachhani ankur_vachhani is offline
Authorized User
 
Join Date: Jan 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ankur_vachhani
Default

Quote:
quote:
for string array you have to take two dimensional char array the above code will not work.

        Follow this , it will work.


#include<stdio.h>

void main()
{
   int num;
   char season[][]={"Jan","Feb","Mar",......"Dec"};

   printf("Input your number:");
   scanf("%d",&num);

   for(int i=1;i<=12;i++)
       if(num==i) {
         printf("%s",season[i-1]);
         break;
        }
}




Reply With Quote