oh yeah. well it happens sometimes

Hi,
Can anyone give me a hint of what I'm doing wrong here?

not pretty, but here's my code...

#include <iostream.h>
#include "apstring.h"
#include <fstream.h>

int main()
{
    apstring user_name;
    int street_num;
    apstring street_name;
    apstring apt_num;
    apstring city;
    apstring state;
    int zip;
    ofstream outfile;
    ifstream infile;

    outfile.open("ADDR.DAT", ios::out);

    cout <<"Enter your name: ";
    getline(cin, user_name);
    cout << "Enter your street number: ";
    cin >> street_num;
    cout << "Enter your street name: ";
    getline(cin, street_name);
    cout << "Enter your apartment or hit enter if none: ";
    cin >> apt_num;
    cout << "Enter your City: ";
    getline(cin, city);
    cout << "Enter your 2 digit state code: ";
    getline(cin, state);
    cout << "Enter your zip code: ";
    cin >> zip;



    outfile << "Name: " << user_name << endl;
    outfile << "Address: " << street_num, street_name << endl;
    outfile << apt_num << endl;
    outfile << city, state, zip << endl;

    outfile.close();

    return 0;

Edited 3 Years Ago by happygeek: fixed formatting

for me the error is. in fact the format for entering strings of characters includding blank spaces is
cin.getline( );

u ppput the cin separately. try with the format given and tell me

I happened to have started this particular thread and just answered back to a post that was e-mailed to me; Because I started this thread.

Don't answer requests for help if you're going to be snippy rather than helpful. It takes away from this forum, which is supposed to be a place for help in programming, right?

I'm not trying to be snippy. I love all life (except for slime molds). I'm suggesting that if you want the most help, post in the right forum. I'd help you if I could, but I don't even know what language that is!

Well, whatever. It's hard to tell an ass from an elbow in type.
I can't seem to get into the other forums-pc just clocks.

Anastacia: Thanks for the advice. I switched and got 6 errors. The code I had only showed 2.

Compiling...
addrfile.cpp
C:\C++ Files\Chapter 08\addrfile.cpp(39) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class apstring' (or there is no acceptable conversion)
C:\C++ Files\Chapter 08\addrfile.cpp(41) : error C2297: '<<' : illegal, right operand has type 'class ostream &(__cdecl *)(class ostream &)'
Error executing cl.exe.

addrfile.obj - 2 error(s), 0 warning(s)

AH!

well maybe you should review the casting operators and the asiignation types. if its from rite to left or vice versa. well i hope i have benn of any help

This article has been dead for over six months. Start a new discussion instead.