After reading almost all I found here and in google, I've not found a simple and direct solution/example about plotting x-y values in c++ (console app win32, the black one) in visual studio 2008. Based on this post, I should use MsChart controls, would anyone be willing please to share a simple example about this?
This post, and many others, talk about libraries that don't belong to visual studio (so they won't compile with the EXE, hence it won't be included as part of the resulting EXE) or having the graphic displayed with excel. I just want to get a simple x-y graphic (and line going through these points), not worried at all if it is the ugliest and simplest graphic in the whole world, but it must appear automatically after my code run (perhaps in a new window or perhaps inside the console?) AND if I run this EXE in another pc, thousands of kilometers away from my pc, the graphic will still appear after the code runs.
Am I asking something too complex? boring?? I hope I could get some answers/examples/solutions instead of this post being closed =) Thanks in advance!
@Koushik thanks again for your support! even though I'm getting the whole picture I need a clear example to get it right, so to voteup I'd like to test this simple example:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double f(const double &x) {
return (
sin(x)*exp(-x));
}
int main()
{
unsigned Nplot = 100;
double x_low = 0.0;
double x_high = 20.0;
double h = (x_high - x_low)/(double)Nplot;
for (unsigned i=0;i<=Nplot;i++)
{
double x = x_low + i*h;
cout << setw(20) << x <<
setw(20) << f(x) << endl;
}
system("pause>nul");
return 0;
}
this is a pretty basic code to generate a sin(x) function. If you copy/paste this in console application Win32 in VC++ 2008 (new project/Visual C++/Win32/console application Win32/empty project/), the data will appear in the screen:
Then, putting these values in Excel gives:
I want this, BUT the output window should appear after the values appear in the console, and more important, the code must not depend on excel or something else external to the visual C++. So, writing some additional code to draw this line and after compiling, both must appear/work in any computer, especially in those without VS or any libraries, just running the EXE in windows, that's all. So, is it possible? could you share a simple code example to draw this line (to add it to the above code)? thanks!