简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM