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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:42:55+00:00 2026-05-28T05:42:55+00:00

In the following program I am having problems with structure initialization. After initialization I

  • 0

In the following program I am having problems with structure initialization. After initialization I need to cout each strcture element using Pointer.

#include <iostream>

using namespace std;

struct student{
int rollno;
float marks;
char name[45];
}*ptr;

int main(){

    //Getting initialization error
student s1[2]={1,50.23,"abc",2,65.54,"def"};

    for(int i=0;i<2;i++){

            //Need to cout using pointers
    cout<<s1[i].rollno<<s1[i].marks<<s1[i].name;
}
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-05-28T05:42:55+00:00Added an answer on May 28, 2026 at 5:42 am

    You should wrap every member of the array in {}:

    student s1[2]={{1,50.23,"abc"},{2,65.54,"def"}};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems compiling the following program. I'm using gcc -framework Foundation inherit8.1m and
I am having problems when using a VB.NET dll in a VB6 program. I
The following program is very simple: it outputs a single dot each half a
I need to have a makefile work under Windows and Cygwin. I having problems
I'm having some problems implementing an exception system in my program. I found somewhere
I am having problems with the following code. What I expect is for the
I'm having problems allocating and deallocating my memory in a recursive C++ program. So
I am having some problems setting up Tomcat for JMX. I added the following
I'm having some problems with a program causing a segmentation fault when run on
I'm having problems interacting with an HTTPS site via Java. My program uses 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.