Thread: Still Doesnt Run, Help?!!

  1. #1
    Registered User
    Join Date
    Sep 2003

    Unhappy Still Doesnt Run, Help?!!

    This is a program that reads data from a disk and outputs data to the same disk.
    The data is:

    The program must exclude the symbols & just output the digits with the '#' starting a new line.

    Output should be:
    #include <fstream>
    #include <iostream>
    #include <cctype>

    using namespace std; //introduces namespace std

    char const nwln = '\n';

    int main ( )
    char ch;
    ifstream data;
    ofstream dataout;
    int n;
    int sum;
    int digit; ("a.\\data.txt");
    if (!data)
    cout << "ERROR -- Cannot open data.txt for input";
    return 1;
    } ("a:\\dataout.txt");
    if (!dataout)
    cout << "ERROR -- Cannot open dataout.txt for output";
    return 1;

    while (data)
    digit = 0;
    while ((ch != '\n') && data)
    if (isdigit(ch))
    digit = ch - '0';
    sum = sum*10 + n;
    if (ch == '#')
    sum = 0;

    data.close(); dataout.close();
    return 0;

    The program compiles fine (with no errors), but it doesnt print my output to the output file on the disk. Please help & tell me what I am doing wrong. This is my 1st program assignment so I am not at all experienced in c++. Thanks in advance.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Thank you for using code tags

  3. #3
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Phildelphia, PA
    Why is it that when noobies write the title to their thread, they often make it sound like someone's life depends on their code running? *sigh*

    You're not reading in from the file. Do that. And read the forum rules.

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  4. #4
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    sum = sum*10 + n;
    Ok, I see trouble up there (whatever you're trying to with it).
    I think "sum" and "n" have to be initialized somewhere in the beginning. And that's right, use code tags because I have trouble understanding your nested loop.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    What Joshdick already said - you're only reading a single byte from the file. How is it that they give you something like this for a first assignment? Everything must be done with small steps. First of all, isolate the problem. Write a dummy app that takes the data from an array of chars and spits it out onto the screen. Then read in a file and output it to the screen. Then work in your algorithm for omitting data, etc.
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  2. how to run an exe command in c++ and get back the results?
    By mitilkhatoon in forum C++ Programming
    Replies: 5
    Last Post: 09-21-2006, 06:00 PM
  3. calculating the mode
    By bigggame in forum C Programming
    Replies: 10
    Last Post: 06-13-2006, 03:04 AM
  4. How I can Run exe file in C++
    By palang in forum C++ Programming
    Replies: 2
    Last Post: 05-10-2006, 11:55 AM
  5. Replies: 2
    Last Post: 10-29-2002, 04:56 PM