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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:43:35+00:00 2026-05-30T01:43:35+00:00

I have a struct as below typedef struct _someStruct { int V1; char V2[10];

  • 0

I have a struct as below

typedef struct _someStruct
{
int V1;
char    V2[10];
} SomeStruct;

SomeStruct *struct;
int elemNo = FillStruct(&struct);
for (i=0; i<elemNo; i++)
    PrintElem(&struct[i]);

Function PrintElem is as below:

void PrintElem(SomeStruct *s)
{
    printf("\n\tV1   : %d\n\tV2   : %s\n", s->V1, s->V2);
}

Code fails in the loop from 2’n or 3’rd element.

Any suggestion on what’s wrong?

EDIT:
Actually the PrintElem was (the reasoin I made it this way is the fact that the real struct had about 30 fields with long names, so I made it to make the code readable) :

void PrintElem(SomeStruct *s)
{
    printf(
        "\n\tV1   : %d"
        "\n\tV2   : %s\n",
        s->V1, s->V2);
}

I didn’t thought this can make a difference, but it did (actually WAS the key of the problem – see my own answer below)
I just post it hoping it will help someone later.

Thanks all for all suggestions and for your time

  • 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-30T01:43:35+00:00Added an answer on May 30, 2026 at 1:43 am

    The correct form of PrintElem should be

    void PrintElem(SomeStruct *s)
    {
    printf(
        "\n\tV1   : %d"\
        "\n\tV2   : %s\n",
        s->V1, s->V2);
    }
    

    Thank you all for help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the STRUCT1 Structure declared as below typedef struct struct1 { short int
I have seen many programs consisting of structures like the one below typedef struct
I have the below code in stdafx.h. using namespace std; typedef struct { DWORD
I have a struct which you see below: typedef struct _List { Person *person;
Ok so I have struct like this typedef struct { float x; float y;
I'm using LLVM-clang on Linux. Suppose in foo.cpp I have: struct Foo { int
I have this struct: struct Map { public int Size; public Map ( int
I have a metafunction: struct METAFUNCION { template<class T> struct apply { typedef T
I have a type defined like this: struct DynTab_s { int object_count; //other fields
So I have this struct composed of three NSPoint structures. typedef struct AOTriangle_ {

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.