c language background music, background image, background font

c language console background color font color, background music

The program is translated by myself, not written by myself

#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#pragma comment(lib, "Winmm.lib")
int main(int argc, char *argv[])
{
    
    
    /* int main()
	playSound(TEXT("a.wav"),0,SND_FIENAME);//a表示需要播放的歌曲,歌曲和程序需要在同一目录
	return O;*/ //表示播放wav格式
     //绝对地址形式
    TCHAR fileName[]="a.mp3";//a表示需要播放的歌曲,歌曲和程序需要在同一目录

    TCHAR shortName[MAX_PATH];
    GetShortPathName(fileName,shortName,sizeof(shortName)/sizeof(TCHAR));
    TCHAR cmd[MAX_PATH+10];
    wsprintf(cmd,"play %s",shortName);
    mciSendString(cmd,NULL, 0, NULL);
    Sleep(5 * 60 * 1000); //这里是防止一播放就结束做的延迟
      return 0;
}

This program is used to play music. It can play two kinds of mp3 and wav. Friends who need it can try it, but you need to note that only one of mp3 and wav can be selected, and two mian cannot appear at the same time.

#include <stdio.h>
#include <windows.h>
 
enum Color
{
    
    
      black, blue, green, lakeBlue, red, purple, yellow, white, gray,
      lightBlue, lightGreen, lightSimpleGreen, lightRed, lightPurple, lightYellow, brightWhite  
};
 
void setColor(unsigned short textColor=0, unsigned short backColor=7){
    
    
	char command[9]="color 07";		//默认颜色	
	command[6]='0'+backColor;		//将backColor变量改为字符型 
	command[7]='0'+textColor;		//将textColor变量改为字符型 
	system(command);				//调用系统函数 
}
 
int main(){
    
    	
	setColor(1,2);
	//setColor(blue,green);
	
	printf("蓝色背景,绿色字体\n\n");
}

In setcolor(,), you can fill in the font and background color serial number you need. There are specific codes. If you have any questions, you can leave a message

Guess you like

Origin blog.csdn.net/xx7755223/article/details/108873171