read pixel value in bmp file [closed]

The following code snippet is not complete, and contains lots of hidden assumptions and bugs. I wrote it from scratch for a university course project from mere observation, where it minimally fulfilled all the requirements. I didn’t work on it any more, because there must be libraries that would do the job way better. Here … Read more

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

Go to Tools -> Compiler Options -> “Compiler” tab Check the checkbox labeled, “Add the following commands when calling the compiler” And add in the text entry box, “-std=c++11” or if that doesn’t work “-std=C++0x“ Should be something like that anyway, I haven’t had Dev C++ installed for many years, so I had to look … Read more

How can I clear console

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 … Read more

Pthreads in C. Simple example doesn’t work [closed]

This line printf(“(%s)”,’Hi. It’s thread number 1′); should be printf(“(%s)”, “Hi. It’s thread number 1”); String literals are enclosed using quotation marks “. Also passing 1 to pthread_join() as 2nd parameter most likley invokes undefined behaviour, as it tells the function to write a value of type void * to address 1, which is not … Read more

Program gives unstable output? [closed]

New code that works: #include <stdio.h> #include <conio.h> #include <string.h> #include <stdlib.h> #include <time.h> int main() { int i,j=0,code,amt, key,lines=0; int id[100],stock[100],k=0; char name[100][20],product[100]; float price[100],sum; float total=0; char ipname[100][20]; int quantity[100], ch; float ipprice[100]; float ipsub[100]; FILE*fp1; fp1=fopen(“Fruit.txt”,”r”); if(fp1==NULL) { printf(“ERROR in opening file\n”); return 1; } else { while((ch=getc(fp1))!=EOF) { if(ch==’\n’) lines++; } … Read more