C help

Discussion in 'Mac Apps and Mac App Store' started by mikeyredk, Nov 27, 2003.

  1. mikeyredk macrumors 65816

    Joined:
    Mar 13, 2003
    #1
    how would do i use file handlers in xcode

    say i wanted to open up a file that has some numbers in it

    i do some arithmetic based on that file then

    i output the results into a diffrent file

    how????
     
  2. mj_1903 macrumors 6502a

    mj_1903

    Joined:
    Feb 3, 2003
    Location:
    Sydney, Australia
    #2
    C or Obj-C?

    If C, use the standard methods that you are used to or have been taught.

    If Obj-C, NSFileHandle is your answer.

    Mat
     
  3. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
    #3
    i see i was suppose to put the file in the build section of the project
     
  4. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
    #4
    just one more if i post it here i might just get it solved had it over at spymac but nothing thats why i think macrumors is alot better cause you guys actually help people

    how does xcode handle complex numbers because trying to get the example program to work
    i looked through the man pages but they didn't help a bit


    Code:
    // includes
    #include <iostream.h>
    #include <complex.h>
    // prototypes
    
    // defines
    #define SKIPLINE cout<<endl
    ///////////////////////////////////////////////////////////////////
    //  Programmer: L A Vercoe   complex.cpp
    //    Date Due: 10/20/97
    //       Input: complex values, be sure to use complex.h
    //     Process: do some complex complications
    //      Output: complex numbers
    //
    
    int main(){
      //declarations
      complex z,z1,z2, i = complex(0,1);
      double x,y;
    
      //heading
      cout<<"\tComplex numbers"<<endl;
    
      //input
      cout<<"Enter in a complex value as realpart: ";
      cin >>x;
      cout<<"\tand the imaginary part: ";
      cin>>y; z = complex(x,y);
      cout<<"Input as complex number (x,y) ";
      cin>>z2;
    
      //<<<process & output>>> do some complex calculations
      cout<<"C's way to output complex numbers: " <<z<<endl;
      cout<<"Another way to output z: "<<real(z2)<<"+"<<imag(z2)<<"i"<<endl;
      cout<<"Multiply z by 2 + 3i = "<<complex(2,3)*z<<endl;
      z1 = sqrt(z);
      cout<<"Square root of z is "<<z1<<endl;
      cout<<"Sin(z) = "<<sin(z)<<endl;
      cout<<"2^z = "<<pow(2,z)<<endl;
      cout<<"e^(pi*i) +1 ="<<exp(M_PI*i)+1<<endl;
      //wrap up
      cout<<endl<<"End of program";
    
    }//main()
    
    again this is the example file he gave us

    i just have to modify it for other equations which are going to be inputed
     
  5. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #5
    Re: C help

    You do it the same way you do it in any other environment. It's simply C++.

    Your textbook probably has examples where they're opening an input stream.

    You might want to try the homework on your own before asking us to do it for you again.
     
  6. mikeyredk thread starter macrumors 65816

    Joined:
    Mar 13, 2003
    #6
    Re: Re: C help

    we don't have a textbook all we got was a handbook of examples and homework
    hey i got to Penn State so don't expect much from the teacher especially a one that is about to retire at the end of the year

    edit:
    i understand how important homework is but what good is homework when you don't understand it or can't even go through the example problems
     

Share This Page