C++ :: How To Play Sound When The Program Ends

Jul 16, 2013

How can I play sound when the program ends? I am using Windows 7.

View 15 Replies


ADVERTISEMENT

C++ :: Play Sound On Key Press - Stops Working After A Few Seconds

Sep 15, 2012

I'm making an apllication which needs to play .wav file when user type something inside QTextEdit. I made some code but after minute or less the sound stops, so I made silly workarround. After 30 clicks I invoke sound->stop(); and then the loop start again, that works, but it's not good, can you give better solution. Here is my code:

Code:

int count = 0;
bool MainWindow::eventFilter(QObject *o, QEvent *e){
if(e->type() == QEvent::KeyPress)
{
tipka->play();
tipka->seek(0);

[Code]...

View 1 Replies View Related

C :: Append Data To Array Of Structures In Memory Then Put In File When Program Ends

Dec 4, 2013

I have a program that stores health information the user inputs, one person at a time. The program works perfectly with the exception of storing the data...I need to open a file and read what health data it has in it already, if any, but store the new changes, and appended data to the array of structures, to the data in memory. All of the information is only saved back in the file once the program terminates. I'm not sure how to go about doing this, so I am also not sure what to put in the function for "Save and Exit" that the user can choose in order to exit the program.

Code:

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct strdatabase
{
char first[20];
char last[20];
char gender[2];

[Code]...

I tried playing around with this bit of code, but I'm not sure if I'm even on the right track.

Code:

FILE *fp;
fp = fopen ("students.txt","rb"); fseek(fp, 0, SEEK_END);
long pos = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *bytes = malloc(pos);
fread(bytes, pos, 1, fp);
fclose(fp);

View 9 Replies View Related

C++ :: How To Play WAV File In A Program

Mar 6, 2014

I understand how to play a .wav file in a program, but I am attempting to "package" the .wav file with the project so that it can be played by another person, on a different machine (namely, my professor). The way I have come to understand this is that if you use the following line of code:

PlaySound(TEXT("C:WindowsMedia
otify.wav"), NULL, SND_FILENAME);

The sound file would not play if it is not in the same location on the other computer. Am I correct? Assuming that I am, I have added the file that I wish to play as a resource in my project, but I can't figure out how to make it play. Looking at MSDN (and other resources) I found the following snippet:

#define MAKEINTRESOURCE
PlaySound(
MAKEINTRESOURCE(L"notify.wav"),
GetModuleHandle(NULL),
SND_RESOURCE);

I get no errors when I build the program, but no sound plays when I run it. I have tried for hours now to figure this out (which is usually enough time for me to sort through the problem) but I have met with no success. This leads me to believe I am either completely off in my assumptions, or I am making a silly mistake.

View 6 Replies View Related

C :: Program To Play Lottery - Limit Between 100-99?

Feb 2, 2015

Suppose you want to develop a program to play lottery. The program randomly generates a Lottery of a three-digit number( any number from 100 to 999), prompts the user to enter a three-digit number, and determines whether the user wins according to the following rule:

1. If the user matches the lottery in exact order , the awards is $100,000.
2. If the user input matches the lottery digits, the awards is $50,000.
3. If two digit in the user input matches a digit in the lottery, the awards is $30,000.
4. If one digit in the user input matches a digit in the lottery,
the awards is $10,000.

Sample:
The winning number is 865.

Your ticket is 865 then 100000
Your tickect is 686, or 568,.. all digits are right but not in order
You get 50000
Your ticket is 860, or 186 .. then 30000
Your ticket is 800, 706, 600.. just one digit much you get
10000
Else
0

Im using if/else statements. Which syntax would I use to figure out the limit between 100-99?

View 1 Replies View Related

C++ :: Program To Play Numbers Guessing Game

Dec 14, 2014

"Write a program to play a numbers guessing game. The user thinks of a number between 1 and 100 and your program asks questions to figure out what the number is (e.g., "Is the number you are thinking of less than 50?"). Your program should be able to identify the number after asking no more than seven questions. Hint: Use < and <= opeartors and the if-else construct."

What I've managed so far, but what I have seems to be lacking

Code:
#include "../../std_lib_facilities.h"

int half(int guess);
int going_up(int i);

int main()

[Code] ....

View 4 Replies View Related

C++ :: Create A Program That Will Play MP3 But Also Display Word File?

Jun 5, 2013

i want to create a program (in c++ or c#) that will play mp3 files but also display a word file with the lyrics of the mp3 song playing. so if i choose a mp3 file from a list, the lyric file for that song should also be displayed. i have all the mp3 and lyric files saved on the computer so my problem is how can i link the files?

View 5 Replies View Related

C/C++ :: Vector Content Goes Away As Soon As Method Ends

Apr 2, 2015

I have this class, Prenumeratorius, it represents a subsriber in this context. Then I have a class Leidinys, which represents a newspaper:

class Leidinys {
private:
string kodas;
string pavadinimas;
double vienetoKaina;

[Code] .....

So in while loop it just reads data, Then I create Prenumeratorius object and store data in it, then I want to add it to correct place by using DėtiPrenumeratorių(), I will show it's content in just a moment. And the last method call - I just add element to another two way list of all subscribers.

So here is content of DėtiPrenumeratorių():

void LeidiniuSarasas::D/>ėtiPrenumeratorių(string kodas, Prenumeratorius &P) {
for(LeidiniuMazgas *dd = p; dd != NULL; dd = dd->Pirmyn()) {
if(dd->Imti().ImtiKodą() == kodas) {
dd->Imti().DėtiPrenumeratorių(P);
}
}
}

It just loops through all newspaprers and searches for the match. I actually tested this method, it works just fine, the problem is one step further:

As you can see, it calls another DėtiPrenumeratorių() method, this time that method puts Prenumeratorius in the vector I showed at the beginning.

The problem is, that when that method is over, vector's content dissapears, I debuged program and saw that, but I can't recognize what is wrong, I added & to all of my method's headers where it accepts that Prenumeratorius object. The same algorithm used to work with one way list.

View 4 Replies View Related

C :: Fscanf Data To Array - It Always Ends Up With Random Numbers

Apr 16, 2014

I am a very fresh c programme user, and need to fscanf data to arrays. Somehow it just doesn't gets recorded, wonder what is wrong with my code?

When I printf the array it always ends up with random numbers. Below is my programme which is just designed to read a doc and print it back out, as well as the text doc it is designed to read.

View 3 Replies View Related

C/C++ :: Exponents Solution Do Not Give Right Answer If Last Number Ends In 5

Mar 19, 2014

I have two unassigned variables A,B . My program goes as follows

#include <iostream>
#include <string>
#include <cmath>
#include <stdlib.h>  
using namespace std;    
bool die (const string & msg);  

[Code] ....

This a program that makes a calculator in which this is a small portion of it, all the exponent numbers work exceptfor anything ending in 5.

Examples go as follow 2^3=8, 3^2=9, 5^2=24

I want to why this happens, is it because they are unassigned variables?

View 1 Replies View Related

C++ :: Beeping Sound When File Changes

Apr 22, 2013

I want to make my computer beep, when a specific file I have already created changes. The idea is this:

I have a personalized e-mail for my website.

When people send me a message, I don't know what happens at all, but at least I can create a file which leaves the comment there. How can I make a program to beep when a file changes?

View 19 Replies View Related

C# :: System Beep Sound?

Apr 22, 2014

I code login form. In the textbox I want to clear if there are some text or close form if there's nothing. The problem is System beep sound occured when the text is cleared. Here's my code

private void tbPassword_TextChanged(object sender, EventArgs e)
{
string _enteredPassword;
while (tbPassword.TextLength == 8)

[Code]....

View 2 Replies View Related

C :: How To Handle Sound And Music Files

Mar 11, 2013

I do not know any of the functions to do this, and when I looked on the internet all the functions I saw were mainly non-standard.

View 12 Replies View Related

C++ :: SDL Sound Thread Delay Between Samples?

Sep 29, 2013

When I use the following handler to handle and mix multiple channels, I get about 1 time unit sound, 5/6 time units silence.

//The volume conversion!
#define VOLUME_PER_SOUND(volume) ((SDL_MIX_MAXVOLUME / 2)*volume)
//Ammount of times to multiply the buffer!
#define MULTIPLIER_BUFFER 1
/* This function is called by SDL whenever the sound card needs more samples to play. It might be called from a separate thread, so we should be careful what we touch. */
void SDLAudioCallback(void *user_data, Uint8 *audio, int length) {

[code]....

(I'm working with 44.1kHz stereo PCM streams)... I've multiplied the stream some times, but to no effect (see the c<MULTIPLIER_BUFFER loop arround the mixing)...

View 4 Replies View Related

Visual C++ :: Cannot Get The Sound To Stop Playing CDA File

Apr 26, 2013

I can not get the sound to stop playing a cda file with MCI_CLOSE. This code works with wav and mpg and avi files.

LONG WindowProc() {
switch (msg) {
case WM_COMMAND:
if (wParam == IDC_PLAY) {
//A CDA File
SendMessage(m_hwMCI,MCIWNDM_OPENA,0,(LPARAM)&chFile);

[Code] .....

View 1 Replies View Related

C++ :: How To Play Simple MP3 Through Mic

Jul 21, 2014

How do I play a simple mp3 through my mic. I plan on using this to just play annoying sounds through skype and games(on windows 7 btw).

View 6 Replies View Related

C++ :: Connect Computers To Play Game?

Nov 16, 2014

I have a Blackjack game that allows users to create a login account and it keeps track of their bet amount, and total bank,etc. How can I connect the program on 2 or more computers so that people can play together?

(A) How would I code it? (B) Can I just connect a USB or HDMI and use the appropriate code? (C) Do they need to be executables instead of just running out of Visual Studio? (D) Can this maybe done over Wi-fi? (E) Or is this something more complicated like over a VPN?

View 2 Replies View Related

C :: Can Play Audio Without Extra Window Showing?

Jul 7, 2013

I got this code from a wiki that taught me how to make C code that plays audio, and with a few changes I was able to get it to take a command-line argument as the music file name. Here it is

Code:
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>

int main(int argc, char *argv[])

[Code] ....

The only problem is, even though I guess it needs to create a window to work with SDL, is there any way you could hide it or something so the user can't see it? I don't really want to see it ( I'm planning on running it from Batch files or C applications as an easy way to play an audio file once ), because if I did, I might as well just use a default audio player instead.

View 3 Replies View Related

C :: Play MP3 File And Delay / Fgets In One Function

Jul 2, 2014

How can i play a mp3 file in the background?How can i rule the volume of the mp3 file?why does delay(0.25) doesnt work in this code?

Code:

FILE *datei;
char line[ANZAHL][LAENGE];
int i ;
datei = fopen ("song.txt", "r");
if (datei != NULL){
for(i = 0; i < ANZAHL;i++) {
delay(0.25);

fgets(line,LAENGE,datei);
printf ("%s

[code]....

View 2 Replies View Related

C++ :: Resetting Board On TicTacToe In Order To Play Again

May 25, 2014

How to reset the board in order to play again without spots already taken.

#include <iostream>
#include<cstdlib>
#include<ctime>
using namespace std;

char location[10] = {'0','1','2','3','4','5','6','7','8','9'};
int displayMenu(int &player, int &win);

[Code] .....

View 1 Replies View Related

Visual C++ :: Add USB Plug And Play Feature Inside DLL

Nov 5, 2013

I have designed a vc++ dll for a controller. I want to add usb plug and play feature inside the dll. I searched on line and came to know:

"If the project is an unmanaged C++ DLL project, then I can only create windows in an unmanaged way, i.e. the usual Win32 API way, such as adding a new dialog box as a resource, or simply using RegisterClassEx() and CreateWindowEx() to create the window yourself, then pump messages for those windows using GetMessage(), TranslateMessage() and DispatchMessage()."

how to use this concept.

I have created a separate application (in delphi 2007) that load this Dll. But I want to add this Plug and Play feature inside me dll.

View 11 Replies View Related

Visual C++ :: Play Youtube Videos In Application?

Mar 26, 2014

I am just at the starting point of this subject. How do i add a video player to my windows form application in vc++?

Can I link youtube videos to that player to be played?

View 2 Replies View Related

C++ :: Rock Paper Scissors Game - How To Add Play Again Option

Apr 1, 2014

So , i had to make an rock paper scissors game . After lot of hard work and struggle ,I completed it but my professor rejected it since I didnot add option where it says "Would you like to play again .Y/N " . The code has too many brackets ! Here is my code

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

// for displaying the outputs to the user; passing string to functions
void user_win() {

[Code] ....

View 1 Replies View Related

C++ :: Number Guessing Game - Play Again Loop Broken

Sep 11, 2013

OK, so the program is working minus the play again loop. I even tried a goto statement for it but no luck. Basically what its doing is after the game runs its course it asks if you would like to play again? If you hit Y it starts over but if you it N it starts over. I want it to out put thank you for playing and close after user hits a button.

// C// Guess My Number
// The classic number guessing game

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

[Code] ....

View 1 Replies View Related

C/C++ :: Play Scales At Certain Frequencies - Creating Array Within Class

Jun 24, 2014

I'm trying to create a program that will play scales at certain frequencies, but my arrays are not initializing correctly. I've read up to double check what i'm doing but it doesn't seem to be working. My only guess is my use of a global variable.

const int NotesInScale = 8;
class Scales {
private:
//all Major Scales
int CMajor[NotesInScale];
int GMajor[NotesInScale];

[Code] ....

i'm simply trying to put the frequencies in the scales (the numbers in the array) but I keep getting an error. I feel its a simple fix but i'm not seeing it.

View 8 Replies View Related

C++ :: Play Audio File As Background While Executing Other Operations

Jun 6, 2013

I need to make a program which can play a audio file as background while executing other operations .

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved