dev-c++

read pixel value in bmp file

允我心安 提交于 2019-11-27 02:58:44
How can I read the color value of 24bit BMP images at all the pixel [h*w] in C or C++ on Windows [better without any 3rd party library]. I got Dev-C++ A working code will be really appreciated as I've never worked on Image reading & have come to SO after Googling [if you can google better than me, plz provide a link]. You can try this one: unsigned char* readBMP(char* filename) { int i; FILE* f = fopen(filename, "rb"); unsigned char info[54]; fread(info, sizeof(unsigned char), 54, f); // read the 54-byte header // extract image height and width from header int width = *(int*)&info[18]; int

Get current username in C++ on Windows

偶尔善良 提交于 2019-11-27 02:39:59
问题 I am attempting to create a program that retrieves the current user's username on Windows using C++. I tried this: char *userName = getenv("LOGNAME"); stringstream ss; string userNameString; ss << userName; ss >> userNameString; cout << "Username: " << userNameString << endl; Nothing is outputted except "Username:". What is the simplest, best way to get the current username? 回答1: Use the Win32API GetUserName function. Example: #include <windows.h> #include <Lmcons.h> char username[UNLEN+1];

How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?

一曲冷凌霜 提交于 2019-11-26 20:21:27
I am just learning how to write range based for loops, but the only problem is that my compiler, Orwell Dev-C++ doesn't seem to support it in its default mode (which is c++98). How can I change this mode to another one that supports this feature (and other features of C++0x). Thanks. Also: This was the error message: [Error] range-based-for loops are not allowed in C++98 mode I run Windows 8 The version I have of Dev C++ is 5.3.0.3 And the compiler is TDM-GCC 4.6.1 64 bit. Thanks to everyone Go to Tools -> Compiler Options -> "Compiler" tab Check the checkbox labeled, " Add the following

Repeated Multiple Definition Errors from including same header in multiple cpps

拜拜、爱过 提交于 2019-11-26 18:59:09
So, no matter what I seem to do, I cannot seem to avoid having Dev C++ spew out numerous Multiple Definition errors as a result of me including the same header file in multiple source code files in the same project. I'd strongly prefer to avoid having to dump all my source code into one file and only include the header once, as that's going to make my file very long and difficult to manage. Essentially, this is what's going on: #ifndef _myheader_h #define _myheader_h typedef struct MYSTRUCT{ int blah; int blah2; } MYSTRUCT; MYSTRUCT Job_Grunt; MYSTRUCT *Grunt = &Job_Grunt; MYSTRUCT Job_Uruk;

How can I compile C++11 code with Orwell Dev-C++?

时光毁灭记忆、已成空白 提交于 2019-11-26 17:19:08
问题 Trying to compile the following code: #include <iostream> #include <memory> struct Foo { Foo() { std::cout << "Foo::Foo\n"; } ~Foo() { std::cout << "Foo::~Foo\n"; } void bar() { std::cout << "Foo::bar\n"; } }; void f(const Foo &foo) { std::cout << "f(const Foo&)\n"; } int main() { std::unique_ptr<Foo> p1(new Foo); // p1 owns Foo if (p1) p1->bar(); { std::unique_ptr<Foo> p2(std::move(p1)); // now p2 owns Foo f(*p2); p1 = std::move(p2); // ownership returns to p1 std::cout << "destroying p2...

read pixel value in bmp file

早过忘川 提交于 2019-11-26 07:59:09
问题 How can I read the color value of 24bit BMP images at all the pixel [h*w] in C or C++ on Windows [better without any 3rd party library]. I got Dev-C++ A working code will be really appreciated as I\'ve never worked on Image reading & have come to SO after Googling [if you can google better than me, plz provide a link]. 回答1: You can try this one: unsigned char* readBMP(char* filename) { int i; FILE* f = fopen(filename, "rb"); unsigned char info[54]; fread(info, sizeof(unsigned char), 54, f); /

Repeated Multiple Definition Errors from including same header in multiple cpps

放肆的年华 提交于 2019-11-26 06:43:52
问题 So, no matter what I seem to do, I cannot seem to avoid having Dev C++ spew out numerous Multiple Definition errors as a result of me including the same header file in multiple source code files in the same project. I\'d strongly prefer to avoid having to dump all my source code into one file and only include the header once, as that\'s going to make my file very long and difficult to manage. Essentially, this is what\'s going on: #ifndef _myheader_h #define _myheader_h typedef struct

How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?

≯℡__Kan透↙ 提交于 2019-11-26 06:03:05
问题 I am just learning how to write range based for loops, but the only problem is that my compiler, Orwell Dev-C++ doesn\'t seem to support it in its default mode (which is c++98). How can I change this mode to another one that supports this feature (and other features of C++0x). Thanks. Also: This was the error message: [Error] range-based-for loops are not allowed in C++98 mode I run Windows 8 The version I have of Dev C++ is 5.3.0.3 And the compiler is TDM-GCC 4.6.1 64 bit. Thanks to everyone

How can I clear console

二次信任 提交于 2019-11-26 01:16:00
问题 As in the title. How can I clear console in C++? 回答1: For pure C++ You can't. C++ doesn't even have the concept of a console. The program could be printing to a printer, outputting straight to a file, or being redirected to the input of another program for all it cares. Even if you could clear the console in C++, it would make those cases significantly messier. See this entry in the comp.lang.c++ FAQ: http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.20 OS-Specific If it still