hey there, good day, i have a problem regarding a csae study, im a newbie and i dont know what's the problem of my source code...help is badly needed,thanks
bryangarcia 0 Newbie Poster
kvprajapati 1,826 Posting Genius Team Colleague
Hi, Good day to you.
I am too, don't know what's the problem of your source code.
mrnutty 761 Senior Poster
I tried sooo hard to become a physic and see your source code, but
no luck. Maybe it would be easier if you posted the code.
bryangarcia 0 Newbie Poster
here's my code
#include<stdio.h>
#include<conio.h>
void main()
{
char name[80];
char month[15];
int day;
clrscr();
puts("Enter username:");
gets(name);
puts("Enter month of birth:");
gets(month);
puts("Enter day of birth:");
scanf("%d",&day);
switch(evaluate_month("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"))
{
case "March" : if(day>=20&&day<=31)
puts("You are an Aries");
puts("Character/Personality: strong willed, driven by money");
else
puts("You are a Pisces");
puts("character/Personality: people person, excellent symphatizer");
break;
case "April" : if(day>=20&&day<=30)
puts("You are a Taurus");
puts("Character/Personality: Good with money, works on a project until the end");
else
puts("You are an Aries");
puts("Character/Personality: strong willed, driven by money");
else
case "May" : if(day>=21&&day<=31)
puts("You are a Gemini");
puts("Character/Personality: natural communicator, highly proactive");
else
puts("You are a Taurus");
puts("character/Personality: Good with money, works on a project until the end");
break;
case "June" : if(day>=21&&day<=30)
puts("You are a Cancer");
puts("Character/Personality: Motivative, creative, good listener");
else
puts("You are a Gemini");
puts("character/Personality: natural communicator, highly proactive");
break;
case "July" : if(day>=21&&day<=31)
puts("You are a Leo");
puts("Character/Personality: Natural born leader, charismatic");
else
puts("You are a Cancer");
puts("character/Personality: Motivative, creative, good listener");
break;
case "August" : if(day>=21&&day<=31)
puts("You are a Virgo");
puts("Character/Personality: detail oriented, visual flair");
else
puts("You are a Leo");
puts("character/Personality: Natural born leader, charismatic");
break;
case "September" : if(day>=23&&day<=30)
puts("You are a Libra");
puts("Character/Personality: organized, in control, fair-minded");
else
puts("You are a Virgo");
puts("character/Personality: detail oriented, visual flair");
break;
case "October" : if(day>=23&&day<=31)
puts("You are a Scorpio");
puts("Character/Personality: ultimate executive, power hungry");
else
puts("You are a Libra");
puts("character/Personality: organized, in control, fair-minded");
break;
case "November" : if(day>=23&&day<=30)
puts("You are a Saggitarius");
puts("Character/Personality: ideal person, patient, persuasive");
else
puts("You are a Scorpio");
puts("character/Personality: ultimate executive, power hungry");
break;
case "December" : if(day>=23&&day<=31)
puts("You are a Capricorn");
puts("Character/Personality: business acumen, strong investigative skills");
else
puts("You are a Saggitarius");
puts("character/Personality: ideal person, patient, persuasive");
break;
case "January" : if(day>=20&&day<=31)
puts("You are an Aquarius");
puts("Character/Personality: determined, perceptive, clever");
else
puts("You are a Capricorn");
puts("character/Personality: business acumen, strong investigative skills");
break;
case "February" : if(day>=20&&day<=29)
puts("You are a Pisces");
puts("Character/Personality: people person, excellent symphatizer");
else
puts("You are a Aquarius");
puts("character/Personality: determined, perceptive, clever");
break;
}
getch();
}
problem is there's an error that displays constant in function main
bryangarcia 0 Newbie Poster
the user will enter his/her month and day of birth and the program should display the corresponding zodiac sign and the character and personality of the person having that kind of zodiac
yellowSnow 607 Posting Whiz in Training
the user will enter his/her month and day of birth and the program should display the corresponding zodiac sign and the character and personality of the person having that kind of zodiac
The problem with your code is that your case labels are wrong. Case labels must be some form of integer constant - you're labels are strings. I suggest that you do a little research and learn how to use switch/case correctly.
Other issues:
1) void main() is WRONG! Use any one of the following for the signature of the main function:
- int main()
- int main(void)
- int main(int argc, char *argv[])
- int main(int argc, char **argv)
2) Try to avoid the use of non-standard functions such as those associated with conio.h. If I was a betting man (and I am), I would bet that you're using Turbo C.
3) In future, when posting code, use code tags - this way your code will be formatted correctly and members of this forum are more likely to help you. Here's a link on how to use code tags - click it, read it and apply it.
http://www.daniweb.com/forums/thread93280.html
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.