Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 221553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:02:39+00:00 2026-05-11T19:02:39+00:00

EDIT: I also got an answer to make sector a vector of vectors: vector<vector<char>>sector;

  • 0

EDIT: I also got an answer to make sector a vector of vectors:

vector<vector<char>>sector;

and that gets rid of the rest of my errors.

EDIT: I’ve made sector an array of pointers as someone suggested, and still get three errors:

EDIT: I have edited the program, but it has not fixed all of the errors:

I have this section of a program:

char* load_data(int begin_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));
char** sector=new char[maxx][maxy];

char* load_data(int begin_point,int num_characters)
{
    seekg(begin_point);
    char* return_val=new char[num_characters+1];
    mapdata.getline(return_val,num_characters);
    return return_val;
}

And I get these errors:

line 5>error C2540: non-constant expression as array bound

line 5>error C2440: ‘initializing’ : cannot convert from ‘char (*)[1]’ to ‘char **’

line 14>error C3861: ‘seekg’: identifier not found

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

How do I fix the errors? Specifically, how to I fix the errors while keeping all my variables global?

Also, if it helps, this is map_data.txt:

10
10
00O
99!

1
55X
19
What is a question?
18
This is an answer
1
1
2
1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:02:39+00:00Added an answer on May 11, 2026 at 7:02 pm

    Well,

    function load_data(int,int) returns a char.
    You are passing that char to the atoi function, that takes a char*. In addition to that, you are probably not including stdlib.h header file!!

    #include <cstdlib>
    int atoi(const char*);
    

    If you dont wan’t to include stdlib.h, then you could declare atoi as extern, but be aware when you compile this module.

    extern int atoi(const char*)
    

    Take into account that the argument of atoi function must be a null-terminated string.

    In order for your code to work, you should make function load data return a char*, not a char.

    char* load_data(int,int);
    

    So, now you could do

    //notice these aren't const, they rely on non-compile time available data.
    int maxx = atoi (load_data(....));
    int maxy = atoi (load_data(....));
    

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

    std::string load_data(int,int)
    

    and then use c_str() method, which returns a C-String from a C++ string.

       const char* std::string:c_str()
    
    
        int maxx = atoi(load_data(....).c_str());
        int maxy = atoi(load_data(....).c_str());
    

    In addition to that, you shouldn’t

    (regarding

    line 5>error C2540: non-constant expression as array bound
    
    line 5>error C2440: 'initializing' : cannot convert from 'char (*)[1]' to 'char **'
    

    )

    char sector[maxx][maxy]; 
    

    You should

     char** sector = new char[maxx][maxy]();
    

    and dont forget to free this memory

    delete[](sector);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 147k
  • Answers 147k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That advice has been floating around for a long time:… May 12, 2026 at 9:15 am
  • Editorial Team
    Editorial Team added an answer VB.NET doubles up the quotes like this: Dim myString As… May 12, 2026 at 9:15 am
  • Editorial Team
    Editorial Team added an answer Decompiling RuntimeType.InvokeMember yields this fragment: if ((bindingFlags & BindingFlags.CreateInstance) !=… May 12, 2026 at 9:15 am

Related Questions

I am a systems programmer, so i just know some basic css/html. I like
I want to use the FTP task in ant, and I have found the
There has got to be an answer to this, but I am a total
I was testing something I read earlier about how random Math.random() really is, and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.