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 7936307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:10:27+00:00 2026-06-03T22:10:27+00:00

I am getting error after fill information.I dont know where did i make mistake.I

  • 0

I am getting error after fill information.I dont know where did i make mistake.I want to get information via structure and then save in biodata.txt file.This is just for starting for my program then i will add “delete edit search” options.

#include <stdio.h>
#include <conio.h>

struct biodata{
       int recno,age;
       char name[20],sex;
       float salary;
}obj;

int main(){
    int addData();
    int showRecord();
    char choice;

    while(1){
        printf("\n\n*****CHOOSE YOUR CHOICE*****\n");
        printf("1) ADD DATA\n");
        printf("2) SHOW RECORD\n");
        printf("Enter your choice : ");

        choice = getche();
        switch(choice){
            case '1' :  
                addData();
                break;
        }
    }
}

int addData(){
     FILE *fp;
     fp = fopen("biodata.txt","w+");

     printf("\n*****ADDING DATA*****\n");
     printf("\nEnter Record No : ");
     scanf("%d",&obj.recno);
     printf("Enter Name : ");

     scanf("%s",obj.name);
     printf("Enter age : ");
     scanf("%d",&obj.age);

     printf("Enter Sex : ");
     scanf("%s",obj.sex);

     printf("Enter Salary : ");
     scanf("%f",&obj.salary);
     fwrite(&obj,sizeof(obj),1,fp);

     fclose(fp);
}
  • 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-03T22:10:29+00:00Added an answer on June 3, 2026 at 10:10 pm

    You are doing:

    printf("Enter Sex : ");
    scanf("%s",obj.sex);
    

    But obj.sex is of char type:

    struct biodata{
            int recno,age;
            char name[20],sex;
            float salary;
    }obj;
    

    Change the scanf to:

    scanf("%c",&obj.sex);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this error after inserting manually a module for oscommerce. I know it
Getting this error after updating OmniAuth gem to 1.1: Started GET /users/auth/facebook for 127.0.0.1
After logged in, I am getting this error: GET http://0.0.0.0:3000/assets/images/ajax-loader.gif 404 (Not Found) error
Keep getting this error after inserting a subdatasheet into a query and trying to
I am getting this error after adding the libxml2.2.dylib file Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1
We are getting this error after upgrading to NHibernate 2.1. [QueryException: Cannot simultaneously fetch
I had a class loader working although I am now getting an error after
I am getting the following error after running git svn rebase: 'update-index --refresh: command
I'm getting a getaddress error and after doing some sleuthing, it looks like it
I am getting error of System.MissingMethodException after I have an optional parameter in one

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.