Thread: sorry for double

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    4

    sorry for double

    I have a program due in couple hours. Professor expects us to know C++ when we never really went over programming; he expects us to just know it .. anyhow


    I have two inputs used with scanf

    it's toll and norm

    these two values need to be put into a data file created by the program

    I need a key that allows me to
    create a "data.txt" file and if the file exist to overwrite it by erased etc.. doesn't matter and put in the things as

    printf(" Toll = %e \m Norm = %e", toll, norm);

    and just exit the program

    i know it's coded in C... but that's all i know
    anyhow if i can code in C or C++ doesnt' matter also could you tell me what library i can use.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >he expects us to just know it
    Somehow I doubt that. Teachers typically do not ask you to do work when the topic was never covered. Perhaps it was a self-study assignment and you just weren't paying attention.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    ...
    
    /* Create a file, erase contents if it exists */
    FILE *fp = fopen ( "data.txt", "w" );
    if ( fp == NULL ) {
      perror ( "fopen" );
      return EXIT_FAILURE;
    }
    Code:
    /* Write your data to the file and exit */
    fprintf ( fp, "Toll = %e \m Norm = %e\n", toll, norm );
    return EXIT_SUCCESS;
    >i know it's coded in C... but that's all i know
    You know, there are these fascinating devices that transfer data through an optical connection straight to your brain. These "books" as they are called, cover many topics, I'm sure you can find several on C and C++. But since most valid C is also valid C++, you should have no problem.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    4
    no seriously... there is no textbook for this class.. they require you to just learn C++ by yourself... i'm not joking... i'm a research school and they usually screw us over like this.

  4. #4
    Registered User
    Join Date
    Jan 2004
    Posts
    4
    thanks for the help btw ..

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >there is no textbook for this class.. they require you to just learn C++ by yourself...
    You can get your own book at a book store or a library and do just that.

    >i'm not joking... i'm a research school and they usually screw us over like this.
    It sounds reasonable to me. Force the student to actually do research instead of hold their hand. That way the weak are weeded out quickly and the strong get a taste of the real world.
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Jan 2004
    Posts
    4
    ok .. seriously.. the prof goes.. "ok guy.. you can turn this in w/ "Fortran, C++, or Matlab. You can't do it in java because i don't have a ta that can read it." this isn't really a "learn to program class"

Popular pages Recent additions subscribe to a feed