dev-c++

Having trouble with fstream in Xcode

六月ゝ 毕业季﹏ 提交于 2020-01-30 08:46:06
问题 I'm having trouble validating the existence of REGISTER.txt for input purposes in a function (see below). My understanding is that if the file doesn't exist, then the file won't be opened and the file stream variable (inData) will be false. Thus, I can use that variable in an if/else statement to verify whether or not it opened. But even though REGISTER.txt is in the same directory as my .cpp file, my code still says that it wasn't opened. Here's the thing though. When I run the same exact

Why is there a compiler error, when declaring an array with size as integer variable?

徘徊边缘 提交于 2020-01-05 08:12:13
问题 In visual studio, I have an error that I didn't have before in Dev-C++: int project = (rand() % 5) + 1 ; int P[project][3]; Compilation: error C2057: expected constant expression error C2466: cannot allocate an array of constant size 0 error C2133: 'P' : unknown size Can you help to understand this error? 回答1: You need to allocate memory dynamically in this case. So you cannot say int P[someVariable] . You need to use int *mem = new int[someVariable] Have a look at this link. 回答2: In C++ you

Get SDL or SDL2 working correctly with Dev-C++

为君一笑 提交于 2020-01-05 04:32:07
问题 I'm really new to programming in C++ and I've seen some tutorials of this programming language. I'm using Dev-C++ 5.11. So I wanted to make a game seeing a tutorial on YouTube, and a step was to set up SDL2 correctly. So I started searching on Google and tried a few things that some pages explained. But it kept showing up errors. Here's the last tutorial I tried with: The compiler log (It's a bit messy): C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe skipping

How to get preprocessed code from Dev-c++ under Windows XP?

时光毁灭记忆、已成空白 提交于 2020-01-05 04:24:16
问题 How to get preprocessed C++ code from DevC++ under Windows XP? I've read about creating gcc -E file.cpp file, but I still can't connect the dots, how to run this file? After I've compiled it everything went as usual. 回答1: You simply can't 'run' a preprocessed file. You can just compile and run it, or inspect it for what the preprocessor produced. E.g. when using GCC you can run gcc file.cpp -E <all preprocessor options as set from the IDE> -o file_preprocessed.cpp to get the file_preprocessed

How do I use libraries / includes in C++?

点点圈 提交于 2020-01-05 04:20:25
问题 Is there a difference between #include and libraries? Or can you just include libraries in your application? Another thing I want to know is if I want to distribute my application how and where do I put the files that I've included in my program? Am I allowed to put the libraries and header files in the same folder as the .cpp files? This confusion arose when I was trying to figure out how to install the SFML library into Dev-C++, now before you tell me that Dev is old and I should change, I

DevC++ (Mingw) Stack Limit

ⅰ亾dé卋堺 提交于 2020-01-03 02:42:07
问题 Is it possible to set the stack limit in DevC++? Basically the same as "ulimit -s" would do on linux. 回答1: Try giving this option to ld (the linker): --stack reserve --stack reserve,commit Specify the number of bytes of memory to reserve (and optionally commit) to be used as stack for this program. The default is 2Mb reserved, 4K committed. [This option is specific to the i386 PE targeted port of the linker] http://sourceware.org/binutils/docs/ld/Options.html#Options 来源: https://stackoverflow

In a switch case statement, it says “duplicate case value” comes up as an error. Anyone know why?

我只是一个虾纸丫 提交于 2019-12-30 23:16:39
问题 I am working on a rock paper scissors program, but this time the computer chooses rock half the time, scissors a third of the time, and paper only one sixth of the time. The way I did this was I enumerated six possible computer choice values: enum choicec {rock1, rock2, rock3, scissors1, scissors2, paper}; choicec computer; But then, after the computer makes its choice, I have to convert these enumerated values to either rock, paper, or scissors. I did this using a switch-case statement:

In a switch case statement, it says “duplicate case value” comes up as an error. Anyone know why?

匆匆过客 提交于 2019-12-30 23:15:20
问题 I am working on a rock paper scissors program, but this time the computer chooses rock half the time, scissors a third of the time, and paper only one sixth of the time. The way I did this was I enumerated six possible computer choice values: enum choicec {rock1, rock2, rock3, scissors1, scissors2, paper}; choicec computer; But then, after the computer makes its choice, I have to convert these enumerated values to either rock, paper, or scissors. I did this using a switch-case statement:

Compile 64-bit binary with MinGW (Dev-C++)

风格不统一 提交于 2019-12-30 05:46:46
问题 It is probably a stupid question but i was searching for the answer from about 3h. ¿How to compile 64-bit binary with (Dev-C++) MinGW? I have readed that MinGW support 64bits by default, but i am unable to active this option. I have tryed "-m64" but it say: "sorry, unimplemented: 64-bit mode not compiled in" I am working on Dev-C++ on Windows-7 I know how to do it on MSVC++, but I don't want MSVC++ (cause of ethical issues) What i am trying to compile, just for testing purpose: #include

eof problem c++

走远了吗. 提交于 2019-12-28 07:02:09
问题 i am using Dev C++ on windows xp #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string STRING; ifstream infile; infile.open ("sample.txt"); while(!infile.eof) { getline(infile,STRING); cout<<STRING; } infile.close(); return 0; } this codes gives the following error C:\C++\read.cpp: In function `int main()': C:\C++\read.cpp:11: error: could not convert `infile.std::basic_ios<_CharT, _Traits>::eof [with _CharT = char, _Traits = std::char_traits<char>