Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to write a code in C++ that prompts the user to enter their name, age, and major, saves it as members of a

I'm trying to write a code in C++ that prompts the user to enter their name, age, and major, saves it as members of a struct, and then outputs the data to screen by calling a void function. However, the function only prints the first 4 characters of the array that is storing the name. Can someone help?

#include

using namespace std;

struct PersonInfo{

char name[50]; int age; string major; };

void print( char Name[], int old, string field); int main() { PersonInfo person1; cout<<"Enter your name: "<>person1.age; cout<<"Enter your major: "; cin>>person1.major;

print(person1.name,person1.age,person1.major);

return 0; }

void print (char Name[], int old, string field) { cout<<"Student Name: "; for(int index = 0;index

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago