First pick a graphics API, for 2d graphs I'd say SDL should do what you need and be easy to use.
Here you can find tutorials on how to set it up to work with various OS/compilers.
Then all you need to do is link it to your project.
Heres some code I made that sets up a screen buffer and draws an animated sine wave:
Code:
#include <SDL\SDL.h>
#include <math.h>
#define GRAPHICS_WIDTH 256
#define GRAPHICS_HEIGHT 256
#define BITDEPTH 32
#define DEG_TO_RAD 0.0174532925
SDL_Surface *screen = NULL; //This will be the screen buffer
SDL_Event event;
void WritePixel(int x, int y, Uint32 col)
{
Uint32 *pix;
pix=screen->pixels+(x+y*GRAPHICS_WIDTH)*4;
*pix=col;
}
int main()
{
//First we set up the screen. If something goes wrong we quit the prog.
if(SDL_Init(SDL_INIT_VIDEO) !=0)
return 1;
screen = SDL_SetVideoMode(GRAPHICS_WIDTH, GRAPHICS_HEIGHT, BITDEPTH, 0);
if(screen == NULL)
return 1;
int x;
int quit = 0;
int anim = 0;
//This is the main loop that repeats until the program is ended
while(!quit)
{
//Start each loop by clearing the screen
SDL_FillRect(screen, NULL, 0);
//Draw stuff
for(x=0; x<GRAPHICS_WIDTH; x++)
WritePixel(x, 128+cos(x*DEG_TO_RAD+anim)*100, 0xFFFFFFFF);
//Flip it into view
if(SDL_Flip(screen)==-1)
return 1;
//This code checks for a keypress
while(SDL_PollEvent(&event))
if(event.type==SDL_KEYDOWN)
quit=1;
SDL_Delay(50);
if(++anim > 359) anim = 0; //Increment animation
}
SDL_Quit();
return 0;
}
You should be able to get it to draw different kinds of graphs by playing around with it.
Hope that helps.