Code:
#include <stdio.h>
#include <stdlib.h>
/*
** main returns an int, this should be
** int main ( void )
*/
main ()
{
printf ("type 'hello'.\n");
/*
** scanf must have a variable to write to, this is undefined.
** Also, the ld flag is for long integers, not strings.
*/
scanf ("%ld");
/*
** This closes main. Not what you want.
*/
}
/*
** Illegal block.
*/
{
/*
** You cannot test scanf like this and strings are surrounded
** by double quotations, not single.
*/
if scanf == 'hello';
printf ("correct\n");
else
printf ("wrong!\n");
/*
** getch is declared in conio.h, yet you did not include it.
*/
getch();
}
This code fixed (somewhat) would look something like this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int main ( void )
{
char word[10];
printf ( "Type hello: " );
scanf ( "%s", word );
if ( strcmp ( word, "hello" ) == 0 )
printf ("correct\n");
else
printf ("wrong!\n");
getch();
return 0;
}
-Prelude