From: neil AT robots DOT ox DOT ac DOT uk (Neil Townsend) Newsgroups: comp.os.msdos.djgpp Subject: Re: why does this not work? Date: Fri, 17 Jul 1998 16:06:35 GMT Organization: None evident here. Lines: 47 Message-ID: <1998Jul17.160635.243@catorobots.ox.ac.uk> References: <6olca3$8ps$1 AT mendelevium DOT btinternet DOT com> NNTP-Posting-Host: cato.robots.ox.ac.uk Originator: neil AT cato To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In comp.os.msdos.djgpp "WillB" writes: >I can't get this program to work. [...] > > >*************************************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) ^^^^^^^^^^^^^^ Herein lies the problem. The '==' comparator only works for numbers. If you want to compare strings you need to use strcmp: if (strcmp(month, "january") == 0) ... strcmp returns 0 for an exact match; non zero otherwise. Further details in the online help[+]. You might also like to check out strcasecmp and strncmp for useful variations on a theme. Yours, Neil [+] Online help as in man pages, info pages or the help menus in RHIDE. -- Neil Townsend +44 (1865) 273121 neil AT robots DOT ox DOT ac DOT uk