I have a homework assignment to write a class that defines a type with "typedef
"
according to the assignment, the type's name must be "complex" with lowercase c, and it must sit in complex.h file
however, i am developing this assignment in xcode
, and this type is already defined there by objective c.
how can i make xcode
favor my type and my file, over the default one, without renaming any of the files and object types ?
complex.h
#ifndef complex_complex_h
#define complex_complex_h
typedef struct complex complex;
struct complex{
double real;
double imaginary;
};
complex A;
complex B;
complex C;
complex D;
complex E;
complex F;
void read_comp (char * complexName, double real, double imaginary);
void print_comp (char * complexName);
#endif
complex.c
#include <stdio.h>
#include <string.h>
#include "complex.h"
complex get_complex_from_name(char * complexName);
complex notFound;
complex get_complex_from_name(char * complexName){
if(strcmp(complexName,"A")==0 ){
return A;
}
if(strcmp(complexName, "B")==0){
return B;
}
if(strcmp(complexName, "C")==0){
return C;
}
if(strcmp(complexName, "D")==0){
return D;
}
if(strcmp(complexName, "E")==0){
return E;
}
if(strcmp(complexName, "F")==0){
return F;
}
return notFound;
}
void read_comp(char *complexName, double real, double imaginary){
struct complex comp = get_complex_from_name(complexName);
comp.real = real;
comp.imaginary = imaginary;
}
void print_comp(char *complexName){
struct complex comp = get_complex_from_name(complexName);
printf("%s=%f+(%f)i",complexName,comp.real, comp.imaginary);
}
compiler throws errors, doesnt know which complex i mean