struct SizeAll{
double year;
double R;
SizeAll() { year = 0; R = 0; }
};
int write_to_file(int count, struct SizeAll *data, char const
*fileName)
{
FILE* fp;
fp = fopen(fileName, "w");
if (fp == NULL) return -1;
while (count-- > 0) {
fprintf(fp, "%d,%d\n", data->year, data->R);
//check for errors writing to file
if (ferror(fp)) return -1;
}
fclose(fp);
return 0;
}
#endif
I've loaded the following in the "main.cpp" equivalent. (Not called "main.cpp", but serves the same purpose.)
#include "stdafx.h"
#include <vector>
#include <stdio.h>
#include "Einstein.h"
#include <math.h>
#include "Form1.h"
The code that actually seeks to generate the vector using the structure definition follows:
int counter,year,retval,count;
vector<SizeAll> Universe;
Universe.resize(5);
vector<SizeAll> *heretis;
char const NameFile[]="D:\\Friedout.csv";
This creates quite a mess. It seems that somehow the "vector" declaration isn't working as the referenced web link seems to suggest that it should. I presume that, as usual, clearing one real error will eliminate the cascade of errors the first real error produces. Can anyone clear this up for me? Why won't VC++ accept the "vector" identifier? Thank you.
The error messages that follow the build attempt are:
Friedman.cpp
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Einstein.h(22): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h(234) : see declaration of 'fopen'
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(80): warning C4067: unexpected tokens following preprocessor directive - expected a newline
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(82): error C2065: 'vector' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(82): error C2275: 'SizeAll' : illegal use of this type as an expression
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Einstein.h(9) : see declaration of 'SizeAll'
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(82): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(83): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(83): error C2228: left of '.resize' must have class/struct/union
type is ''unknown-type''
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(84): error C2065: 'vector' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(84): error C2275: 'SizeAll' : illegal use of this type as an expression
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Einstein.h(9) : see declaration of 'SizeAll'
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(84): error C2065: 'heretis' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(87): error C2065: 'heretis' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(87): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(88): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(88): error C2228: left of '.R' must have class/struct/union
type is ''unknown-type''
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(89): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(89): error C2228: left of '.year' must have class/struct/union
type is ''unknown-type''
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(92): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(92): error C2228: left of '.year' must have class/struct/union
type is ''unknown-type''
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(93): error C2065: 'Universe' : undeclared identifier
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(93): error C2228: left of '.R' must have class/struct/union
type is ''unknown-type''
d:\documents and settings\xx\my documents\visual studio 2010\projects\friedman\friedman\Form1.h(96): error C2065: 'heretis' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Bookmarks