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 6761137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:09:00+00:00 2026-05-26T14:09:00+00:00

I am trying to write a function to change some folder names, but I

  • 0

I am trying to write a function to change some folder names, but I am having difficulties in the actual declaration.

Here is my code:

void ChangeVersion(char* NewVer)
{
    ifstream show_current_version;
    show_current_version.open(*removed*);
    char show_current_version_var[1024];
    if (show_current_version.is_open())
    {
        while (!show_current_version.eof())
        {
              show_current_version >> show_current_version_var;
        }                                         
    }
    show_current_version.close();
    // show_current_version_var is old version
    char OldVersion[1024] = show_current_version_var;

    // start rename
    cout << "Changing versions...";
    rename("*removed*", OldVersion);
    rename(NewVer, "*removed*");
    cout << "done!" << endl; 
} 

As you can tell, I am new to c++…

I have read on various c++ tutorial websites, that if you want a function to not return anything, then you declare it as void. However when I did this, my compiler says invalid initializer. I am using dev-cpp.

I am thinking it is because my function is outputting text, but on the websites, the void function has some cout statements…

I have tried initializing it with char*, like my other functions, yet I get the same error. Same with int and char.

Thank you for reading.

  • 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-26T14:09:01+00:00Added an answer on May 26, 2026 at 2:09 pm

    You really should give the output of the compiler a closer look. It generally tells you what line contains the error, which gives you a lot to work with.

    Getting to the particular problem the offending line (from what I gather, havent tried compiling) is:

    char OldVersion[1024] = show_current_version_var;
    

    You can’t assign a variable to a static array like that. There’s only a handful of things one can use to initialize a static array. For example:

    char OldVersion[1024] = "Static string";
    char example[1024] = { 0 };
    

    Try doing:

    char OldVersion[1024];
    strncpy(OldVersion, show_current_version_var, 1024);
    // Null-terminate the string for good measure
    OldVersion[1023] = 0;
    

    Or simply use show_current_version_var where you would use OldVersion (I see no reason to copy the string in the code you pasted).

    Anyway, I don’t know what you’re trying to accomplish, but you really should read up on C++. It’s a rather tricky language to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a jQuery function to change out href of a link,
I'm trying to write a function in assembly (but lets assume language agnostic for
I'm trying to write some text to a canvas element, but it seems that
I have come up to issues while I'm trying to write some classes, here
I am trying to write some code to optimize some Open GL functions for
I'm fairly new to JavaScript and am trying to write some code that lists
Im trying to write a function for adding category: function addCategory() { $cname =
I'm trying to write a function that formats every (string) member/variable in an object,
I am trying to write a function that will pull the name of a
I'm trying to write a function that is able to determine whether a string

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.