c++ - How can I make this declaration work? -


Edit: I also got an answer to the field vectors:

  vector & Lt; Vector & lt; Four & gt; & Gt; Area;  

And it gets rid of all my mistakes.

EDIT: I have made a sector an array of pointers as someone has suggested, and still has received three errors:

EDIT: I Edited, but has not fixed all the errors:

I have this part of a program:

  Char * load_data (int start_point, int num_characters) ; Ifstream mapdata ("map_data.txt"); Const int maxx = atoi (load_data (0,2)); Const int maxy = atoi (load_data (2,2)); Four ** field = new four [max] [max]; Char * load_data (int start_point, int num_characters) {seekg (begin_point); Char * return_val = new char [num_characters + 1]; Mapdata.getline (return_val, NUM_CHARACTERS); Return return_value; }  

and I get these errors:

line 5> error C2540: Constrained expression in the form of array

line 5> error C2440: 'start': 'char (*) [1]' to 'four **'

line 14> error can not be changed with C3861: 'seekg': identifier not found

per seekg: Yes, I know that I have to include fstream, I included it in main.cpp, this is a separate .h file which is also included in main.cpp.

How can I fix errors? Specifically, how can I fix errors while keeping all my variables global?

In addition, if it helps, then map_data.txt:

  10 10 00 o 99! What is 1 55 x 19 question? 18 This is an answer 1 1 2 1  

Good,

Function load_data (int, int) returns a four return you are going around the Aroo function, which uses four *. Additionally, you are probably not including the stdlib.h header file!

  #include & lt; Cstdlib & gt; Int'l (Cost four *);  

If you do not want to include stdlib.h, you can declare atoi as extern, but be careful when you compile this module.

   

Consider the logic of the atoi function to be a redundant string.

In order for your code to work, you should return the function load data to a four *, no four.

  char * load_data (int, int);  

So, now you can do this

  // Notice are not const, they rely on data available at non-compile time int maxx = Atoi (load_data (....)); Int maxy = atoi (load_data (....));  

If you are in C ++, the load_data function can return a std :: string.

  Use the std :: string load_data (int, int) > 

and then the c_str () method, which uses C-string as C ++ String gives.

  const char * std :: string: c_str () int maxx = angle (load_data (....). C_str ()); Int maxy = atoi (load_data (....). C_str ()); In addition to this, you should not be  

(

  line 5> error about C2540: non-continuous expression head Tied line 5> error C2440: 'start': 'char (*) [1]' to 'four **'  

) can not be converted

  four regions [max] [max];  

You

  four ** region = new four [maxx] [maxy] ();  

And do not forget to free this memory

  delete [] (Sector);  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -