Text file error

\users\y410p\desktop\c++ programs\chapter 3\chapter 8\asds\project eye\appointments.cpp(1): fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
#include <iomanip>

using namespace std;

int write(void);
int write(void)
{
    ofstream outfile;
    char firstname[18],
         lastname[25],
         address[28],
         city[18],
         state[3],
         zipcode[6],
         phonenumber[11];
    int index;

    outfile.open("textfile2.txt.txt",ios::app);

    cout<<"Enter your First Name: ";
    cin>>firstname;
    cin.ignore();
    cout<<"Enter your Last Name: ";
    cin>>lastname;
    cin.ignore();
    cout<<"Enter your Address: ";
    cin.getline(address, sizeof(address));
    cin.ignore();
    cout<<"Enter your City: ";
    cin.getline(city, 18);
    cout<<"Enter your State: ";
    cin.getline(state, sizeof(state));
    cin.ignore();
    cout<<"Enter your ZipCode: ";
    cin.getline(zipcode, 6);
    cout<<"Enter your Phone Number: ";
    cin.getline(phonenumber, sizeof(phonenumber));
    cin.ignore();

    outfile<<firstname<<setw(2)<<lastname<<setw(2)<<address<<setw(2)<<city<<setw(2)<<state<<setw(2)<<zipcode<<setw(2)<<phonenumber<<endl;
    outfile.close();
    cout<<"Writing Completed."<<endl;
    return 0;
}

int read(void);
int read(void)
{
    ifstream input;
    input.open("L:\\BU-521\\textfile2.txt.txt",ios::in);

    char firstname[18],
         lastname[25],
         address[28],
         city[18],
         state[3],
         zipcode[6],
         phonenumber[11];

    int counter =1;
    while(!input.eof())
    {
        input>>firstname>>lastname>>address>>city>>state>>zipcode>>phonenumber;
        cout<<"Information Required. "<<endl;
        cout<<firstname<<setw(1)<<lastname<<endl;
        cout<<address<<endl;
        cout<<city<<setw(2)<<state<<setw(2)<<zipcode<<endl;
        cout<<phonenumber<<endl;
        counter++;
        cout<<endl;
    }
    cout<<"Reading Completed. "<<endl;
    input.close();
    return 0;
}

int main()
{
      int choice;
      char ch;

      do{
          cout<<endl;
          cout<<"Please choose from the following: \n";
          cout<<"\t1. Read Data. \n";
          cout<<"\t2. Write Data. \n";
          cout<<"\t3. Quit. \n";
          cout<<endl;
          cout<<"Your choice: ";
          cin>>choice;


           switch(choice)
          {
             case 1:
                     read();
                   break;
             case 2:
                     write();
                   break;
             case 3:

                   break;
             default:
                   cout<<"\tInvalid entry!"<<endl;
           }
           cout<<"\nWould you like to try again (y/n): ";
           cin>>ch;

     }while(ch == 'y' || ch == 'Y');

      system("PAUSE");
      return 0;
}
Try <iostream> without the .h
thanks do you know how to solve the mistake 'int' unexpected


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <iomanip>

using namespace std;

int write(void);
int write(void)
{
    ofstream outfile;
    char firstname[4],
         lastname[4],
         contact[8],
         Datetime[8],
    int index;

    outfile.open("textfile2.txt.txt",ios::app);

    cout<<"Enter your First Name: ";
    cin>>firstname;
    cin.ignore();
    cout<<"Enter your Last Name: ";
    cin>>lastname;
    cin.ignore();
    cout<<"Enter your Contact: ";
    cin.getline(contact, sizeof(contact));
    cin.ignore();
    cout<<"Enter your Date and Time: ";
    cin.getline(Datetime, sizeof(Datetime));
    cin.ignore();
   

    outfile<<firstname<<setw(2)<<lastname<<setw(2)<<contact<<setw(2)<<Datetime<<endl;
    outfile.close();
    cout<<"Writing Completed."<<endl;
    return 0;
}

int read(void);
int read(void)
{
    ifstream input;
    input.open("textfile2.txt.txt",ios::in);
	{
    char firstname[4],
         lastname[4],
         contact[8],
         Datetime[8];

    
    while(!input.eof())
        input>>firstname>>lastname>>contact>>Datetime;
        cout<<"Information Required. "<<endl;
        cout<<firstname<<setw(1)<<lastname<<endl;
        cout<<contact<<endl;
        cout<<Datetime<<endl;
  
        cout<<endl;
    }
    cout<<"Reading Completed. "<<endl;
    input.close();
    return 0;
}

int main()
{
      int choice;
      char ch;

      do{
          cout<<endl;
          cout<<"Please choose from the following: \n";
          cout<<"\t1. Read Data. \n";
          cout<<"\t2. Write Data. \n";
          cout<<"\t3. Quit. \n";
          cout<<endl;
          cout<<"Your choice: ";
          cin>>choice;


           switch(choice)
          {
             case 1:
                     read();
                   break;
             case 2:
                     write();
                   break;
             case 3:

                   break;
             default:
                   cout<<"\tInvalid entry!"<<endl;
           }
           cout<<"\nWould you like to try again (y/n): ";
           cin>>ch;

     }
	  while(ch == 'y' || ch == 'Y');

      system("PAUSE");
      return 0;
}
In function 'int write()': 16:5: error: expected unqualified-id before 'int'


1
2
3
4
5
6
7
8
int write(void)
{
    ofstream outfile;
    char firstname[4],
         lastname[4],
         contact[8],
         Datetime[8],  <-- should be a semi-colon
    int index;
Topic archived. No new replies allowed.