getline()-ing a char?

In a struct, I have this:

1
2
const int Len = 40;
char fullname[Len];


In another file, I must get data from the user to put into the array... Though I'm not sure how to go about it. I could use strings, but I have no idea how to convert them into arrays.

TL;DR:
I must get a series of chars from the user (by strings or whatever) and put them into an array in a struct.
use a function called strcpy, you must have #include <string.h>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include <string.h>
using namespace std;

struct things
{
  char FullName[40];
};



int main()
{
  char name[40];
  things stuff;
  cout<<"Enter your name:  ";
  cin.getline(name, 41);
  strcpy(stuff.FullName, name);
  cout << stuff.FullName << endl;

return 0;
}
Topic archived. No new replies allowed.