ZwertY
February 27th, 2011, 02:20 AM
Hey guys,
i learned c for about a year now, and i want do make my own header. It should just be a function which ends the programm. So i already wrote one, but obviously there is something wrong with it...
#ifndef PROGCLOSE_H
#define PROGCLOSE_H
int closeProg()
{ int close123 = 0;
printf("Press a buton to end the programm");
scanf("%d", &close123);
if (close123 != 0)
{
printf("Programm was closed \n \n");
return 0;
}
}
#endif
So there it is. I want to just put int closeProg() into my source code. But if i do it just simply nothing happens. It's the complete same thing as if it was not in there. Of course i included the header file by putting #include "close.h" at the top of my source, but as i said nothing happens. So does anyone know why that is?
Thanks in advance.
Oh and by the way, it works perfectly if i just put
int close123 = 0;
printf("Press button bla bla");
scanf("%d", &close123);
if (close123 != 0)
{
printf("Programm was closed \n \n");
return 0;
}
at the very end of my SC. But i want to simplify it by including the header file.
i learned c for about a year now, and i want do make my own header. It should just be a function which ends the programm. So i already wrote one, but obviously there is something wrong with it...
#ifndef PROGCLOSE_H
#define PROGCLOSE_H
int closeProg()
{ int close123 = 0;
printf("Press a buton to end the programm");
scanf("%d", &close123);
if (close123 != 0)
{
printf("Programm was closed \n \n");
return 0;
}
}
#endif
So there it is. I want to just put int closeProg() into my source code. But if i do it just simply nothing happens. It's the complete same thing as if it was not in there. Of course i included the header file by putting #include "close.h" at the top of my source, but as i said nothing happens. So does anyone know why that is?
Thanks in advance.
Oh and by the way, it works perfectly if i just put
int close123 = 0;
printf("Press button bla bla");
scanf("%d", &close123);
if (close123 != 0)
{
printf("Programm was closed \n \n");
return 0;
}
at the very end of my SC. But i want to simplify it by including the header file.