Naveen
Naveen

Reputation: 105

How can i add an icon to my console program in C?

#include <stdio.h>
#include <windows.h>

int main()
{
   SetConsoleTitle("MathTable Gen [beta]");
   system("color 17");
   system("mode 55,40");
   int num,x;
   printf("\n\t\tGenerate table of : ");
   scanf("%d",&num);
   if (num <=1000)
   {
        for (x=0;x<=10;x=x+1)
   {
    printf("\n\t%d\tx\t%d\t=\t%d\n\n",num,x,num*x);
   }
printf("\n           Created by : Naveen Niraula !");
}
else
{
    system("mode 70,15");
    SetConsoleTitle("MathTable Gen [beta] - Error!");
    system("cls");
    printf("\n\n\n\n\n  You either entered an invalid number or entered a value too big !\n\n\t \t  \tBetter try again. :)");
    printf("\n\n\n\t\t    Created by : Naveen Niraula !");
    getch();
    return;
}
getch();
return();
}

Okay this is my first C program after learning a little bit.
Now my only question is how can i add an ICON to my program ? Oh and i am using Code::Blocks as my C IDE. I hope someone can help me with clearance ?

Upvotes: 0

Views: 451

Answers (1)

s_b
s_b

Reputation: 491

To add an icon you'll need to write a resource script (.rc) with the following entry

IDI_ICON1               ICON                    "myIcon.ico"

which will add the myIcon file to your application. Then the rc file needs to be compiled using the resource compiler (rc.exe) which you should find in your default compiler installation folder. This generates a .res file which you can pass to the linker with the other object files of your program.

refer the following link for more information : about resource files

you can download the resource compiler with the SDK package here

Upvotes: 3

Related Questions