Question
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: "<
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started