From: Allens Newsgroups: comp.os.msdos.djgpp Subject: Re: why does this not work? Date: Thu, 16 Jul 1998 19:06:01 +0100 Organization: Cable Online Lines: 57 Message-ID: <35AE4109.65A2@cableol.co.uk> References: <6olca3$8ps$1 AT mendelevium DOT btinternet DOT com> NNTP-Posting-Host: 194.168.181.11 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk WillB wrote: > > I can't get this program to work. It is supposed to ask for name, age, and > month of birth, then print the name and age, then if else the different > months to choose the correct description of their horoscope. DJGPP tells me > january is undeclared and febuary is undeclared. What am I doing wrong. I'm > sorry if I have done something stupid- but I am new to this. Program is > below (in C) > > Thanks in advance, > Will > exSite DOT Website AT btinternet DOT com > > *************************************PROGRAM******************* > > #include > > int main() > { > > char name[20]; > short age; > char month[10]; > > printf("hello, and welcome to my little program\n"); > > printf("Please enter your name...\n"); > scanf("%s", name); > printf("Please enter your age...\n"); > scanf("%i", &age); > printf("please enter the month you were born in lowercase..\n"); > scanf("%s", month); > > printf("So your name is %s and your age is %i \n", name, age); > > if(month==january) > printf("And your star sign is Capricorn(22 Dec-20 Jan) or > Aquarius(21 Jan-19 Feb)\n"); > else if(month==february) > pritnf("And your star sign is Aquarius(21 Jan-19 Feb) or Pisces(20 > Feb-20 Mar)\n"); > else > printf("And I can't be arsed to write 'if else's' to find your star > sign - try January or February\n"); > > printf("Thank you - and goodbye....\n"); > > return 0; > } First, by saying if(month==january)you are comparing to variables. if(month=="january") would be correct, but to compare strings you have to use if (strcmp("january",month)){ instead. Also, you have spelt prinf wrong on the february bit, but that is just a little mistake. Hope it works now, but I haven't checked it. Peter Allen