How to work with Dev C++ - dev-c++

I am new in programming. but i know turbo C & i can work with it. But how to work on Dev C++?
i means 1.How to Compile & 2. How to Run. I have Windows so if anyone help me with proper example than it will be great.

Dev c++ is very simple! To do the basic, Open you file, compile and run using the menu Execute!
However, if u are starting something new now, I would suggest you consider using eclipse. It is not so easy in the first days but the long term gain is giant!
I would like to improve my answer... I suggested that you should consider using eclipse. I still think that eclipse is great. Furthermore, I had had some problems with the old version of dev c++. After reading the comment of #Orwell (which provided facts that I didn't know), I checked the new version and the issues that I had had before disappeared. So, the big picture of dev c++ is that it is a program that works well and it is very simple. There is a cost to start using eclipse!
Example:
#include <iostream>
using namespace std;
int fibonacci(int n){
if(n==1)return 0;
if(n==2)return 1;
if(n>=3)return fibonacci(n-1)+fibonacci(n-2);
}
int main(){
//
int n =10;
cout << "The element of the Fibonacci series is " << fibonacci(n) << "\n";
return 0;
}

Related

antivirus popup while using c++

I am new to C++.I am following freeCodeCamp.org tutorial on C++.
The program looks like this-
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int luckyNums[] = {4,8,15,16,23,42};
cout << luckyNums[2];
return 0;
}
since I had VS code already installed I did not install code blocks.
Every time I run the above program I get an error "Access is denied". Also at the same time McAfee pops up saying "we just stopped a virus". I couldn't find a solution to this on Google anywhere.
When I was trying to do something with the code, in line 6 I did
cout << luckyNums[2] << endl;
and it worked and returned 15 but now the problem was I didn't understand why it worked because Mike got the result without doing this in code blocks.
Mike is the person giving the tutorial on freeCodeCamp.org

How do I graph data in c++?

I am trying to make a graph using graphics.h in c++. I was following a tutorial on youtube. It seems that either due to the age of the video (perhaps the syntax has changed slightly?) or a problem on my end; I cannot even get a separate window for my graph to open. I am in completely uncharted waters for me as the limit of my coding knowledge is what you would expect to learn from a first-semester coding class. I am using DEV C++ and am compiling using "TDM-GCC 4.9.2 32-bit Release" (because the 64 bit release gives me an error in "Makefile.win" that scares me) and my program exits with a return value of 3221225477. What am i doing wrong?
#include"graphics.h"
#include<math.h>
#include<conio.h>
#include<iostream>
using namespace std;
int main() {
initwindow(800,600);
int x,y;
line(0,300,getmaxx(),300);
line(400,0,400,getmaxy());
float pi=3.14159;
for(int i=-360;i<=360;i++){
x=(int)400+i;
y=(int)300-sin(i*pi/100)*25;
putpixel(x,y,WHITE);
}
getch();
closegraph();
return 0;
}
According to your issue and exit-code, the return value in hex is 0xC0000005 or STATUS_ACCESS_VIOLATION. But most developers didn't even bother to learn out-dated legacy API and I can not help you to find the exact line (use debugger, it shows you the exact line, still not the reason).
But to answer your question in the title, well, according to what free framework one uses (Qt or XWidget), the method differs, for Qt (which I would recommend) simply override paint-event and use QPainter renderer to show your QPath data.
Don't reinvent the wheel (or render-system in this case), your course and/or book may soon introduce you to one of the mentioned frameworks.

GDALDriver::Create GTiff Segmentation Fault

I am new to using GDAL, and am having trouble creating a GDALDataset using the GDALDriver::Create() method. In this case, I am using C++. Ultimately I am trying to create a raster and write values from an array to the raster. A minimal working example of the code that generates the problem of creating a dataset is given here:
#include <iostream>
#include </usr/include/gdal/gdal_priv.h>
int main(){
std::cout << "starting GDAL business\n";
const char *raster_format = "GTiff";
GDALDriver *g_driver;
g_driver = GetGDALDriverManager()->GetDriverByName(raster_format);
GDALDataset *g_dataset;
const char *test_file = "test_file.tif";
char **raster_creation_options = NULL;
std::cout << "raster options created\n";
g_dataset = g_driver->Create(test_file,
100,200,1,GDT_Float32,
raster_creation_options); //<--- seg faults
std::cout << "dataset created\n";
}
The resulting console looks like:
starting GDAL business
raster options created
Segmentation fault (core dumped)
I am just following the basic API tutorial (Link), but am encountering this problem. I am on Ubuntu 14.04, using the repository's libgdal packages.
Can anyone shed some light on this problem?
I know this is an old question and the issue has probably long since been resolved, but I figured I would throw my answer into the ring. After all, I was directed here when I had this problem and it seems like the question has a fair amount of views.
If your code is not working, and you are having trouble loading the driver, I would suggest adding the line GDALAllRegister();. I was following the same tutorial as you, and they mention adding this line at the top of the tutorial, but if you're like my and rushed right to the part you needed, the Create part of the tutorial, you probably overlooked that step.
Hopefully this answer helps someone, if not the original author of the question.

Weird compiling error with CodeBlocks - c++

that's my first use to code block but it hasn't gone fine ,, i face a really weird problem
i cant even describe it so i will just tell you what's happened.
the problem is that the ide dont compile my project even if the code were correct
its just open a new tab that called "iostream" and the console window appears but empty
why do that happens ?
look to the code which the ide face a problem while compiling it ,, simplest code ever
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
and this is the compiling results...
thats all..
will codeblocks stop annoying me ?
This line is not valid syntax
usingnamespace std;
Those are two separate keywords
using namespace std;
And since you are just starting C++, Lesson 1: Don't do that.

Eclipse C++ default "Hello World" errors

This is my first post here, so sorry if it's a little bit bad :I but I have a problem. When I tried to make a Hello World C++ project in Eclipse (first time trying c++) I tried to build the project and run it, but it said that there are errors. Here is the code:
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
And also here is a screenshot of the errors:
I tried looking but couldn't find a solution, so sorry if I look stupid for being a total noob :\ All and any help is appreciated. :) Thanks!
The code looks good to me. I think you didn't setup C++ in Eclipse correctly.
Follow the step-by-step setup here. You should be able to work it out after correct setup.