View Full Version : C help
mikeyredk
Nov 27, 2003, 10:30 AM
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????
mj_1903
Nov 27, 2003, 10:47 AM
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
mikeyredk
Nov 27, 2003, 12:00 PM
i see i was suppose to put the file in the build section of the project
mikeyredk
Nov 27, 2003, 01:29 PM
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
// 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
bousozoku
Nov 27, 2003, 09:48 PM
Originally posted by mikeyredk
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????
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.
mikeyredk
Nov 27, 2003, 11:39 PM
Originally posted by bousozoku
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.
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
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.