Home Varying string variable in an if condition
Reply: 0

Varying string variable in an if condition

user804
1#
user804 Published in June 23, 2018, 7:55 am

I used this program to take input mm as the month of the year and print out the name of the month:

#include <stdio.h>
#include <string.h>
int main(){
int mm;
printf("input month ");
scanf("%d", &mm);
char mname[9];
if (mm == 1) {mname = "January";}
if (mm == 2) {mname = "February";}
if (mm == 3) {mname = "March";}
if (mm == 4) {mname = "April";}
if (mm == 5) {mname = "May";}
if (mm == 6) {mname = "June";}
if (mm == 7) {mname = "July";}
if (mm == 8) {mname = "August";}
if (mm == 9) {mname = "September";}
if (mm == 10) {mname = "October";}
if (mm == 11) {mname = "November";}
if (mm == 12) {mname = "December";}
printf("%d is month %s", mm, mname);

return 0;
}

it gave an error assignment to expression with array type. please help

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.329275 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO