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

  • SEARCH
  • Home
  • 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 8931673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:09:50+00:00 2026-06-15T09:09:50+00:00

I am trying to get multiple entries for my struct via the keyboard. I

  • 0

I am trying to get multiple entries for my struct via the keyboard. I think I am wrong inside of scanf but I am not sure where I am wrong. Thanks!

Here is what I have:

#include <stdio.h>
#include <math.h>

int main()
{

    //define the structure
    struct course
    {
        char title[20];
        int num;
    } ;
    // end structure define

    //define the variable  
    struct course classes;

    printf("Enter a course title and course number");
    scanf("%s %d", classes[3].title, &classes.num);

    return 0;
}
  • 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-06-15T09:09:51+00:00Added an answer on June 15, 2026 at 9:09 am

    Fix the code as Carl said and it works fine:

    #include <stdio.h>
    
    int main()
    {
        struct course
        {
            char title[20];
            int num;
        } ;
    
        struct course class;
    
        printf("Enter a course title and course number");
        scanf("%s %d", class.title, &class.num);
        printf("%s %d", class.title, class.num);
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call Get-WMIObject (gwmi) on multiple computers selected via Get-ADComputer as a
I am trying to get multiple values is strtotime to work together but they
I am trying to get a regular expression to find multiple entries of my
I am currently trying to get multiple xml files into my xsl file to
I have a question about the JFileChooser in Swing. I'm trying to get multiple
In short: How do I access LocationManagerService.mProximityAlerts ? I'm trying to get multiple ProximityAlerts
I am trying to get a multiple upload library working for my Codeigniter based
I am trying to get my query to grab multiple rows while returning the
I'm trying to get col1 values for certain multiple col2 values. For example: I
I am trying to get jquery validate to work on multiple fields. Reason being

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.