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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:06:08+00:00 2026-05-28T00:06:08+00:00

I get Use of undeclared identifier ‘data’ when I compile that code. As you

  • 0

I get “Use of undeclared identifier ‘data'” when I compile that code. As you can see the problem is that add_student function can’t “see” student array.

What to do so to work properly ?

#include <stdio.h>

typedef struct {
    char *name;
    int  age;
    char *sex;
    int  class;
}student;


void add_student(int, char*, int, char*, int);

int main (int argc, const char * argv[])
{
    student data[5];

    add_student(5, "Mery", 3, "female", 8);
    return 0;
}

void add_student(int sequence, char *name, int age, char *sex, int class) {
    strcpy(data[sequence].name, name);
    data[sequence].age[13];
    strcpy(data[sequence].sex, sex);
    data[sequence].class[2];
}
  • 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-28T00:06:09+00:00Added an answer on May 28, 2026 at 12:06 am

    The cleanest way to fix this is by passing data as an additional argument to add_student().

    There are other errors, such as

    1. passing 5 as the value of sequence and then using it to index into data;
    2. the use of strcpy() is incorrect as you haven’t allocated memory for the name and sex fields;
    3. the expressions data[sequence].age[13] and data[sequence].class[2] are not valid C.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get string like main.c:11: error: 'qz' undeclared (first use in this function) like
I always seem to use Get when working with data (strongly typed or otherwise)
From what I can gather, there are three categories: Never use GET and use
hI, I'm trying to get this code from Larry Nyhoff's book to compile in
I am getting a use of undeclared identifier error in my json but I
How is it possible to get/use/return a thread from an execute queue ( =
I'm trying to get LinqPad use my dbml model so I could analyze a
I am trying to use 'get_posts' to pick up posts that are in two
Obviously I could create a Calendar object with the date and use get(DAY) on
When I use file_get_contents and pass it as a parameter to another function, without

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.