利用VS2013中的C++编辑器进行操作,没有成功播放音乐,想问下原因是什么?
#include<iostream>
#include<windows.h>
#pragma comment (lib,"winmm.lib")
using namespace std;
class automobile
{
private:
char type[20];
char color[20];
float price;
int carry_weight;
int carry_customer;
public:
void set_data(char *t, char *c, float pri, int cw, int cc);
void movecar(int l, int k);
void downcar(int l);
void horming(int num);
void play_MP3(char *ps);
char *show_type(){ return type; };
};
void automobile::set_data(char *t, char *c, float pri, int cw, int cc)
{
strcpy_s(type, t);
strcpy_s(color, c);
price = pri;
carry_weight = cw;
carry_customer = cc;
}
void automobile::movecar(int l, int k)
{
cout << "\n" << type << "水平直线运动" << endl;
for (int i = 0; i < l;i++)
{
cout << ' ' << "o_o";
Sleep(1000 / k);
cout << "\b\b\b";
}
}
void automobile::downcar(int l)
{
cout << "\n" << type << "垂直下降运动:" << endl;
for (int i = 0; i < l;i++)
{
cout << "o_o";
Sleep(500);
cout << "\b\b\b" << " ";
cout << endl;
}
}
void automobile::horming(int num)
{
for (int i = 0; i < num;i++)
{
cout << type;
cout << '\007' << " di..." << endl;
Sleep(1000);
}
}
void automobile::play_MP3(char *ps)
{
char str[100] = "play ";
strcat_s(str, ps);
cout << str;
mciSendStringA(str, NULL, 0, NULL);
char a;
cin >> a; //输入任何字符结束播放
}
int main()
{
automobile nison;
char tp[] = "yyida";
char ys[] = "white";
nison.set_data(tp, ys, 200000, 5, 3);
nison.horming(3);
nison.movecar(5, 3);
nison.downcar(3);
char mp[] = "C:\\songtian.mp3";
nison.play_MP3(mp);
return 0;
}
第一次求助,谢谢啦