C++ XCODE MAC OSX?????

Hello,
I am attempting to output with fprintf within C++ in Xcode for the purposes of Physics work. Previously I have used Turbo C++ on a PC and had no issues with similar outputs as below... I am trying to send data to a .csv file in order to create graphs/charts in xcel, but the debugger HATES the output I attempting. Can someone PLEASE help me and tell me how to send output out of xcode and into either xcel or mac's numbers program? What is wrong with my code? THANKS I AM AT MY WIT'S END!

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>

int main ()
{ int ia,ja,ib=1,jb=1,n=1,t=1;
float Ia[25],Ja[25],C[25][25],Wbb[25][25],xl[25][25],xr[25][25],Pr[25][25],Nr[25][25],max,r1,H=0;

max=RAND_MAX;
FILE * Project1;
Project1 = fopen (“Users/Dave/Desktop/Project1.csv”,”w”);

Ia[n]=3;
Ja[n]=3;
for(t=1;t<100;++t) //time step counter
{
n=1;
for(n=1;n<26;++n) //# of states to look at
{
ia=Ia[n];
ja=Ja[n];
ib=1;


for(ib=1;ib<6;++ib) //determine I[n]'s C[ia][ja] values (initially will be the same due to ICs)
{
jb=1;
for(jb=1;jb<6;++jb)
{
C[ia][ja]=100*(ia-ib)^2+100*(ja-jb)^2+1;
}
}
//fprintf(Project1, "%d,%d,%d,%f\n",n,ia,ja,C[ia][ja]);


ib=1;
for(ib=1;ib<6;++ib) //determine Wsrs and delta x's for each system I[n] {
{
jb=1;
for(jb=1;jb<6;++jb)
{
Wbb[ib][jb]=C[ia][ja]/((100)*(ia-ib)^2+100*(ja-jb)^2+1);
xl[1][1]=0;
xr[ib][jb]=xl[ib][jb]+Wbb[ib][jb];
//fprintf(Project1,"%d,%d,%f,%f,%f",ib,jb,Wbb[ib][jb],xl[ib][jb],xr[ib][jb]);
xl[ib][jb+1]=xr[ib][jb];
}
}


r1=rand()/max; //randomly select new state and determine it's ib,jb value and reassign to new ia, ja at next time step
ib=1;
for(ib=1;ib<6;++ib)
{
jb=1;
for(jb=1;jb<6;++jb)
{
if(r1<xr[ib][jb] & r1>xl[ib][jb])
Nr[ib][jb]++;
Ia[n]=ib;
Ja[n]=jb;
}
}
}

ib=1;
for(ib=1;ib<6;++ib)
{
jb=1;
for(jb=1;jb<6;++jb)
{
Pr[ib][jb]=Nr[ib][jb]/25;
H=Pr[ib][jb]*log(Pr[ib][jb])+H; //Compute Total Entropy Function of all systems by adding each systems entropy
}
}

//fprintf(Project1,"%f",H); //print out the Entropy at each time step
}
}
Last edited on
Topic archived. No new replies allowed.