I know you can call functions to bring up new code at a particular point in a program. I was told you can call sound files such as sound.mp3 and also picture files like picture.jpg, is this right? and how would you call such a thing into a program?
(lines 21 && 44)and then some picture at the end of the program?
#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
string item;
double wholeSale;
double markup;
double total;
double calculateRetail( double, double); // function prototype
cout << "Input an item for sale.\n";
getline(cin, item);
cout << "Enter the items whole sale price: " << endl;
cin >> wholeSale;
//here i would like to call a sound file that would sound like a amber alert on radio stations, lol.
if( wholeSale < 0 )
{
cout << "ERROR, price of item cannot be less than zero(0)." << endl;
cin >> wholeSale;
}
cout << "Enter items percent of markup: " << endl;
cin >> markup;
if(markup < 0)
{
cout << "ERROR, Percent values cannot be less than zero(0)." << endl;
cin >> markup;
}
markup = (markup * .01) + 1;
total = calculateRetail(wholeSale, markup); // Function call
cout << fixed << setprecision(2);
//here i would like to output a "cha ching" sound file.
cout << "The retail price for " << item << " is " << total << "." << endl;
system("pause");
return 0;
}
//other function
double calculateRetail( double wholeSale, double markup)
{
double answer;// local varible its scope is only in the function
answer = (wholeSale * markup);
return answer;
}
The reason you have to download these libraries is support for sound and images is not directly built into c++. The alternative to downloading libraries would be to write your own.
so c++ cant just call some sound file like it calls a .txt file, the /a is calling a sound file build into the c++ compiler?
ill read up on what you provided, thanks.
The '\a' sound is not "built-in" to the c++ language. The reason it makes a sound is the computer you are using makes a sound when it receives a beep code. The '\a' outputs a code that most consoles recognize as the system beep code. Just like 'D' is recognized as printing a D or '\n' is recognized as a new line. You can find more character codes here: http://www.asciitable.com/
(Also if you look at character code 07h that is what '\a' represents - the bell/beep code)
C++ does come default with opening filestreams which can be used for .txt and any other file even .mp3.
In fact, if you read through these open source libraries you will eventually find a call to opening a .mp3 filestream, but if you just open a .mp3 file with notepad you will see a lot of random characters. FMOD already has code that knows what to do with those random characters and how to send it to the operating system to make sound.