C++ read file

There is one line in file data.txt:
Name Sur 122

I need to read this line into 2 variables: pvd = "Name Sur " - 11 characters, numb = 122.

#include <iostream>
#include <fstream>
using namespace std;

void main()
{
char pvd[11];
int numb;

ifstream File("data.txt");

File >> pvd >> numb;

File.close();

cout << pvd << " " << numb;
}

But it reads that line just until the space.
What's wrong?
All that command does is read up to the space.

1
2
3
4

File >> pvd;
File >> numb;


Should work fine.
No, it doesnt :(
Can I get a little more detail as to the issue? What is the output that you are gettting? What is the output that you expect? What is the input from the file that you are reading?
Input: Name Sur 122
Output: pvd = Name, numb = -858993460
Expected output: pvd = Name Sur , numb = 122
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    char pvd[50] = {0}; //make sure we have a buffer long enough
    int numb;

    ifstream File("data.txt");

    //I'll let you figure out the next 3 lines
     File >> pvd;
    pvd[strlen(pvd)] =' ';
    File >> &pvd[strlen(pvd)];

   
 File >> numb;

    File.close();

    cout << pvd << " " << numb; 
Thx :)
Topic archived. No new replies allowed.