reading files specified by user

hi,
im making a program where the user will enter a file number and it will open the file and take the number stored in the file and add 1 to it, when opening the file i combine int a and ".txt" as the file name but when the program is run it creates a file called txt, so i think it's ignoring the integer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <fstream.h>
using namespace std;

int main()
{
    int a;
    char b;
    ofstream write;
    ifstream read;
    cin >>a;
    
    read.open (a + ".txt"); //this doesnt work
    b=read.get();
    b=b+1;
    read.close();
    
    write.open(a + ".txt"); //this doesnt work either
    write<<b;
    write.close();
}
    

Thanks any help is appreciated
Topic archived. No new replies allowed.