error in CodeBlocks compilre ??

hello everyone again I so sorry for all these question :'(

I need help again please I get this error in codeblocks compiler :


https://i.postimg.cc/TPYTpPyS/Untitled.png

this is the code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>

using namespace std;

int main(){

  ifstream file("emoji.txt");
  if (file.fail()) cout << "Failed to open inputile" << endl;

  vector<string> names;
  string line;
  while (file >> line) names.push_back(line.append(".png"));


  for (size_t i = 0; i < names.size(); i++)

  {

      int success = rename(string(" (" + to_string(i) + ").png").c_str(), names[i].c_str());
      if [success !=0] cout << "Failed to rename" << names[i] << endl;

  }

    return 0;

}




and I know why get this error ... because in the video he was use visual studio compiler but I'm use just codeblocks compiler :

https://i.postimg.cc/c180K2Hs/1111111111.png

so how i can fix this error please ❤️ ❤️ ❤️

Ah this function for Renaming multiple files (images) with a list of filenames (C++) if any other function please give me it =D

Last edited on
Why do you continue to post pictures of your IDE?
The error message is text. Post the text. Do not post a picture of the text

Isn't it a pain to take all those screenshots when you could simply copy and paste the error like everyone else?
@mbozzi

hhhhhh Thanks bro ❤️ ❤️ ❤️

Yes Yes it's very pain :'( but I should do it because I want who can help me understand very well my problem =D
Last edited on
Taking a screenshot helps us less than just posting the text.

Anyway, std::to_string is C++11.
Go into your compiler settings and make sure you have -std=c++11 or -std=c++0x enabled.

Ideally, you should update your compiler to a version that supports C++11 by default.
http://wiki.codeblocks.org/index.php/MinGW_installation

Also, it's

if (condition)

not

if [condition]
Last edited on
CodeBlocks, cstdio, mingw and to_string are a notorious combination that you might spend hours and hours on to resolve.

The quickest and most reliable way to resolve this well known and long-standing issue, if you can, is to junk CodeBlocks and use Visual Studio, XCode or something similar.

CodeBlocks is rubbish. If you look at the revision list for it CodeBlocks is virtually unsupported.

https://stackoverflow.com/questions/41410952/to-string-not-working-in-codeblocks-16-01?noredirect=1&lq=1

http://www.codeblocks.org/

So now there's No way to do it in this version of CodeBlocks because my computer is very old I can't install Visual Studio or update CodeBlocks :'(
@Ganado

Thanks bro ❤️ ❤️ ❤️

I have c++11 :

https://i.postimg.cc/131vh7Tv/Untitled.png

and yes it is : if() Not if[]
Last edited on

where is this guy @seeplus I'm sure he can do it hhhhhh :'(
Last edited on
What version of Code::Blocks do you use ?
When I change line 25 to if (success !=0) it works with Code::Blocks 17.12

@Thomas1965

Thanks Thanks Thanks bro I'm update it to 17.12 from 16.1 and it's work now
coooooooooooooooooooooooooooooooool ❤️ ❤️ ❤️
Last edited on
Please stop posting links to screenshots. They aren't readable. If you're getting compiler errors, copy and paste the errors.

This should compile as C++98 - but it's been so long ago that I used C++98 that I've forgotten what you couldn't do in it.........

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
	ifstream file("emoji.txt");

	if (!file.is_open()) {
		cout << "Failed to open inputfile" << endl;
		return 1;
	}

	vector<string> names;

	for (string line; file >> line; )
		names.push_back(line + ".png");

	for (size_t i = 0; i < names.size(); ++i)
		if (rename((" (" + to_string(i) + ").png").c_str(), names[i].c_str()) != 0)
			cout << "Failed to rename" << names[i] << endl;
}


Last edited on
to_string requires C++11

@Thomas1965

Thank Thanks Thanks bro I'm update it to 17.12 from 16.1 and it's work now ❤️ ❤️ ❤️
coooooooooooooooooooooooooooool
If you are updating Code::Blocks get the latest version, 20.03, instead of 17.12.
@seeplus


Thank you so much bro I'm do it by update Code::Blocks to 17.12 =D

@Furry Guy

my computer is very old just pentium 4 :'(

https://i.postimg.cc/VLYHBJwL/111111.png
Code Blocks 20.03 provides 32-bit downloads as well.
http://www.codeblocks.org/downloads/26
codeblocks-20.03mingw-32bit-setup.exe

But again, the compiler that comes with Code Blocks by default can be swapped out with another compiler.
my computer is very old just pentium 4 :'(

You could use Visual Studio 2019 Community, it requires at minimum a 1.8 GHz processor.
https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements

I'm not saying it wouldn't be slooooooooooower than molasses, but you appear to meet the minimum requirements.

Code::Blocks would be a better fit for your antique CPU. Even 20.03 will work since there are 32-bit downloads available. The compiler "under the hood" is not a major determining factor.
http://forums.codeblocks.org/index.php?topic=16779.0

There are no longer any official 32-bit downloads for 17.12 or earlier. Only for 20.03.

MinGW is a decent for-Windows GNU compiler. Getting the MinGW C::B setup would save you a lot of steps of having to get a compiler integrated into the IDE.
MinGW | Minimalist GNU for Windows - http://mingw.org/
Topic archived. No new replies allowed.