#include %26lt;stdio.h%26gt;
typedef enum {FALSE, TRUE} BOOL;
void main(void)
{
// Mainline Variable Declarations
// FILE * output = stdout;
// FILE * input = stdin;
char name[20]; //length limited upto 20 chars only
printf("Enter name:");
scanf("%s",name);
// type int needed for 400,800,1600,3200
int ISO=0;
// type float needed for 2 2.8 4 5.6 8 11 16 22
float aperture=0;
BOOL ReadSpeed = FALSE;
BOOL ReadAperture = FALSE;
while ((ReadSpeed == FALSE) || (ReadAperture == FALSE))
{
if (ReadSpeed == FALSE)
{
printf("Hello %s Enter ISO setting: ");
scanf("%d",%26amp;ISO);
// flush the input stream in case of bad input
fflush(stdin);
printf("\n");
............
The line printf outputs like this when I compile it :
Hello %26lt;null%26gt; Enter ISO setting . Anyone know what I'm doing wrong ?
.... need help with my c code please?
Change that printf statement to:
printf("Hello %s Enter ISO setting: ", name);
Reply:I think you meant to print "Hello (name) Enter ISO settings: ", so you need to write printf like this:
printf("Hello %s Enter ISO settings: ", name);
Reply:Get rid of the %s placeholder. C is expecting a string argument and you aren't passing one, hence the NULL. You're lucky, this would crash on some systems.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment