metamorphy
Programmer
Why doesn't this program allow me to input anything into
name? Am I misusing cin.getline()? Is there a more effective way to accomplish what I am trying to do here?
#include <stdio.h>
#include <iostream.h>
struct database{
int integer;
char name[50];
char notes[200];} record[100];
void main()
{
cout << "Enter an integer: ";
cin >> record[1].integer;
cout << "\nEnter a name: ";
cin.getline(record[1].name,sizeof(record[1].name)-1);
cout << "\nEnter some notes: ";
cin.getline(record[1].notes,sizeof(record[1].notes)-1);
cout << "\nRECORD:" << record[1].integer;
cout << "\nNAME:" << record[1].name;
cout << "\nNOTES:" << record[1].notes;
}
name? Am I misusing cin.getline()? Is there a more effective way to accomplish what I am trying to do here?
#include <stdio.h>
#include <iostream.h>
struct database{
int integer;
char name[50];
char notes[200];} record[100];
void main()
{
cout << "Enter an integer: ";
cin >> record[1].integer;
cout << "\nEnter a name: ";
cin.getline(record[1].name,sizeof(record[1].name)-1);
cout << "\nEnter some notes: ";
cin.getline(record[1].notes,sizeof(record[1].notes)-1);
cout << "\nRECORD:" << record[1].integer;
cout << "\nNAME:" << record[1].name;
cout << "\nNOTES:" << record[1].notes;
}