Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help in simple file input output program
#4
Well, so running the code I found a few errors listed here in the order of chance to be what causes the program to fail to compile:
  1. emp.eof()
    should probably be
    empfile.eof()
    .
  2. cout<
    should probably be
    cout<<
    .
  3. goto
    -statements end with a
    ;
    not a
    :
    .
  4. int *get_code()
    should probably be
    int get_code()
    .
  5. main
    is supposed to return
    int
    .
  6. Initialization of
    ofstream o;
    is skipped, when jumping to
    case 5:
    . (add
    {
    after
    case 4:
    , and
    }
    before
    case 5:
    )
  7. using namespace std;
    to drag whatever is in the headers into the global namespace.
  8. ios::noreplace
    isn't a thing anymore, same thing goes for
    clrscr()
    and
    sleep()
    .
  9. #include <iostream>
    and
    #include <fstream>
    , instead of
    #include <fstream.h>
    .
On top of that I also got a few warnings:
  1. nc=emp.get_code()
    should probably be
    nc==emp.get_code()
    .
  2. gets
    is super unsafe (what happens if the user enters more characters than you have in your buffer?). Consider using
    fgets
    or
    getline
    [/codei]).
  3. empfile.seekp(empfile.tellg() - sizeof(emp)
    is ambiguous. Cast
    sizeof(emp)
    to
    streamlen
    (probably safe to ignore, and Turbo C++ might not support
    streamlen
    ).

Lastly, please find some way to rate whoever is teaching you as lowly as possible, because using Turbo C++ in a world where GCC, and Clang exist is plain and simply unacceptable.

(also consider deleting this thread to remove the evidence of you asking for help, if this works)
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Reply
Thanks given by: MangaD , InPhiKnight , A-Man


Messages In This Thread
RE: Help in simple file input output program - by Som1Lse - 12-08-2016, 02:49 PM



Users browsing this thread: 1 Guest(s)