Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6357273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:07:58+00:00 2026-05-24T23:07:58+00:00

I think my problem is something simple, but I’m not seeing it. I’m new

  • 0

I think my problem is something simple, but I’m not seeing it. I’m new to programming in C and this is an effort to see what I’ve absorbed, bit by bit. I think I must have not properly defined my char variable “dopt”. Hope you can help. Here’s the code:

#include <stdio.h>


int dbref();
int aart();
int wgame();
int calc();
int txtoc();

int amin()

{
char dopt;
printf("What should this program have the options of doing?\n");
printf("A) Reference a database?\n");
printf("B) Print ascii art?\n");
printf("C) Make a noun, pronoun, object, verb word game?\n");
printf("D) Being a calculator?\n");
printf("E) creating a text file and save it as a .c file?\n");
printf("F) or should it just terminate?\n");
scanf("%c", &dopt);
if (dopt == a || A)
    { dbref();}
if (dopt== b || B)
     { aart();}
if ( dopt==c || C)
    { wgame();}
if ( dopt==d || D)
     { calc();}
if ( dopt==e || E)
    { txtoc();}
if (  dopt==f || F)
    { return 0;}
return 1;
}

dbref()
{
printf("reference A correct");
return 2;
}

aart()
{
printf("reference B correct");
return 3;

}

wgame()
{
printf("reference C correct");
return 4;

}

calc()
{
printf("reference D correct");
return 5;

}

txtoc()
{
printf("reference E correct");
 return 6;

}

As a sidenote, the printf routines in the functions are just to verify that the menu is flowing correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:07:59+00:00Added an answer on May 24, 2026 at 11:07 pm

    a is not the same as 'a'

    • a is an identifier
    • 'a' is a character

    You want to match that if the contents of the char variable dopt is any of the characters. So you need to compare the ASCII values of the characters, which can be found by placing the character within a single quotes.

    Therefore

    if (dopt == a || A)
       { dbref();}
    

    a and A are treated as two separate variables (names), which are not declared (at least locally) .

    Thus it should be

    if (dopt == 'a' || 'A')
        { dbref();}
    

    Here 'a' and 'A' are character constants and not variable names.

    BUT 'a' || 'A' is always 1 because || is logical OR operator. Therefore dopt will always be false (almost). But if you want to make the effect that if dopt is either 'a' or 'A' then call dbref () then you need to do the following:

    if ((dopt == 'a') || (dopt == 'A'))
        { dbref();}
    

    or also

    if (toupper (dopt) == 'A') // similar with tolower ()
        { dbref();}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this is probably something simple, but after an hour of searching, I've
I have this problem. i think it is simple but i just couldn't get
It might be very simple but I think I am missing something. I have
I think I might be having a stack overflow problem or something similar in
I have a problem drawing something quickly in .NET. I don't think that any
Simple problem (I think): I want to be able to invoke a click method
I think that this problem can be sorted using reflection (a technology which I'm
My problem is one that you would think is quite common, but I haven't
I think this might be a problem with the theme I'm using ( Nitobe
I have a problem which I think is related to forward declarations, but perhaps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.