Hi, I am trying to a play a .wav file in a C++ program. I think my code is OK, but when it plays, it plays the default windows 'error' sound, not my .wav file. This is the program: [code] #include <iostream> #include <windows.h> #include <mmsystem.h> #pragma comment(lib,"Winmm.lib") using namespace std; int main() { for( int a = 0;a<10;a++) { PlaySound((LPCWSTR)"tone.wav", 0, SND_LOOP|SND_ASYNC); Sleep(1000); } return 0; } [/code] How can i add the .wav file so it is found? In the Visual Studio 2005 soulution explorer I right click on Resource Files>Add>Resource, but can't find an option for .wav. …

Member Avatar
Member Avatar
+0 forum 9

Hi, I am new to C# and Forms/GUIs. Basically I am trying to pass a value in a textBox to my programs program.cs file where I can apply my programs logic, but I'm stuck with how to do this. To get started all I am making is a form which takes two variables, and I want to add those variables together and display the sum in a third text box. I am stuck though with getting the value entered by the user into my program.cs file where I can use it/add the two values together. My skeleton app is as …

Member Avatar
Member Avatar
+0 forum 5

Hi there, I'm completely new to Java. I am trying to use [I]import[/I] in a project, but despite using what I think is the right code, my application fails to build. When I build my app, it builds and runs fine, but I want to use [I]JFileChooser[/I], so add this line of code to my program, it is the very first line of code in my app: [CODE]import javax.swing.JFileChooser;[/CODE] Now when I try to build it fails. If I comment it out it does build. Do I have to download JFileChooser and link it into my project or something similar? …

Member Avatar
Member Avatar
+0 forum 1

Hi, I have an expression tree in which the nodes are operators (union, intersection etc represented by a string "/u") or the nodes are std::sets. How could I access the std::set's values in order to carry out the tree evaluation using the operator functions(set_union(), set_intersection() etc) ? The expressions are pre and postfix. Thanks for any help, it's most appreciated.

Member Avatar
Member Avatar
+0 forum 3

Hi, I am starting to try and create windows forms using C# in Visual Studio 2008. I added a button to my form, and when I clicked it, the event handler code was generated as expected: [code=c#] private void button1_Click(object sender, EventArgs e) { } [/code] The book I am following also says that when I delete a control from the form, the code for it will also be deleted, but when I right click on the button and select Delete, the event handler code is still there. The button however has gone from the form. I tried to rebuild …

Member Avatar
Member Avatar
+0 forum 2

Hi there, I am passing command line arguments to a program. I know traditionally people declare argc and argv like this: [code=c++] int main(int argc, char *argv[] [/code] but I need to pass bigger numbers into my program (type long long). Is it OK to use the following: [code=c++] int main(long long argc, char *argv[] [/code] Or am I making a mistake with this? Sorry for the newbie question, just couldn't find any examples of this being done, hence my doubt. Thanks for any advice on this! Carrots :)

Member Avatar
Member Avatar
+0 forum 1

Hi, I have in my database the location of some images I want to display, all formatted as: [quote] ../images/products/1.jpg ../images/products/1.jpg [/quote] I'm trying to diplay them in a webpage but get the following error: [QUOTE] x Warning: substr() expects parameter 1 to be string, array given in C:\xampp\htdocs\mysite\index.php x Warning: substr() expects parameter 1 to be string, array given in C:\xampp\htdocs\mysite\index.php [/QUOTE] The 'x's display fine, matching the number of row in the database, but the images do not. Here is my code: [code=php] <?php $query = "SELECT product_Picture from products LIMIT 0, 10"; $result = mysql_query($query) or die(mysql_error()); …

Member Avatar
Member Avatar
+0 forum 4

Hi, I was wondering if anyone can see why the substr_replace() function isn't replacing the 'XXXXX' with the random integer I am creating in the script below: [code=php] <?php $password = rand(12345,98765); $stringtoparse = 'Your new password is XXXXX'; substr_replace($stringtoparse,$password,18); echo $stringtoparse; ?> [/code] When I run this, I still have the following being output: [quote] Your new password is XXXXX [/quote] Can anyone see why the function wouldn't be working as I expect and replace the XXXXX with the random number being generated? Many thanks for any help! :)

Member Avatar
Member Avatar
+0 forum 2

Hi there, Looking for some advice regarding the following hierarchy structure: [url]http://i40.tinypic.com/9a1us0.jpg[/url] I'm storing base class pointers in a std::list in my program: [CODE=c++]list<Vehicle*>mylist[/CODE] Is it possible for me to use Pure Virtual functions in the base class? For example: [code=c++]virtual int getMPG() = 0;[/code] Seems fine, as all derived types have an _mpg data member. But, if I use: [code=c++]virtual int getNoOfDoors() = 0;[/code] I am having problems as Boat objects don't have a _noOfDoors data member. Only those derived from Car do. So I am wondering, is it not possible for me to use Pure Virtual functions in …

Member Avatar
Member Avatar
+0 forum 1

Hi there, I have a problem in that my derived concrete classes are loosing the data members which are part of my derived classes. I have wrote a simple program to show the problem. [B]GrandParent.h :[/B] [code=c++] #ifndef GRANDPARENT_H #define GRANDPARENT_H using namespace std; #include <string> /******************************************************** Abstract base class ********************************************************/ class GrandParent { public: //constructor GrandParent(string name); //Getter string getName() const { return _name; } private: protected: string _name; }; //constructor GrandParent::GrandParent(string name) { _name = name; } /******************************************************** Concrete parent class ********************************************************/ class ConcreteParent : public GrandParent { public: //constructor ConcreteParent(string name, string address); //Getter string getAddress() { …

Member Avatar
Member Avatar
+0 forum 3

Hi, I'm having trouble understanding how I should use pure virtual functions in my inheritance tree. I've drawn a class diagram which shows what I'm trying to achieve: [img]http://i42.tinypic.com/2qjdttd.jpg[/img] Here is what I've written: [B]main.cpp[/B] [code] #include <iostream> #include <string> #include <list> #include "base.h" using namespace std; int main() { list<GrandParent*>theList; GrandParent *ptr = new Parent("a","b"); theList.push_back( ptr ); GrandParent *ptr1 = new Child("a","b","c"); theList.push_back( ptr1 ); system ("pause"); return 0; } [/code] [B]base.h[/B] [code] #ifndef BASE_H #define BASE_H using namespace std; #include <string> /******************************************************** Abstract base/grandparent class AIRCRAFT ********************************************************/ class GrandParent { public: //constructor GrandParent(string name); //Getter string getName() …

Member Avatar
Member Avatar
+0 forum 6

Hi, I was trying to display an image in a thread, but despite using [img][/img] tags, it just parses the link. Is there a way of posting an image in the post/thread? Thanks a lot!

Member Avatar
Member Avatar
+0 forum 3

Hi there, I'm trying to return base class pointers from the two classes 'base' and 'child', but I keep on getting a build error of "1 unresolved externals". I think it may be because I am linking all the files together incorrectly. When I comment out the problem line in main.cpp it builds fine, but when I try to use it (and return a base class pointer), this is when I cannot build the program. I have copy and pasted my code exactly here: [b]child.cpp :[/b] [code=c++] #include "base.h" #include "child.h" #include <iostream> #include <string> using namespace std; //Child class …

Member Avatar
Member Avatar
+0 forum 1

Hi, I have been wrestling with this program all day and am looking for some help. I have never separated a program up before into separate files (main.cpp, base.h and base.cpp). What I'm trying to do is call a function from main() and have that function return a pointer to a new object. Once the pointer has been returned, I'm trying to push it into the std::list. The problem I've been having is this compile error: [QUOTE]illegal call of non-static member function[/QUOTE] I have wrote a simple version of my program which reproduces the same problem: [B]main.cpp :[/B] [code=c++] #include …

Member Avatar
Member Avatar
+0 forum 2

Hi there, I am trying to read values from a .txt file using stringstreams and plan to enter the values into a map, I am reading into a buffer, but it contains spaces and I believe a character which represent the end of line. Here is my program so far: [code] #include <map> #include <iostream> #include <fstream> #include <sstream> using namespace std; int main() { //I eventually plan to enter the values into a map map<string, string> mapname; //Ask for the filename to open char fileName[20]; cout << "Enter the name of the .txt file that you would like to …

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm trying to construct my first Doubly Linked List, but am having trouble compiling. This is my program: [B]main.cpp :[/B] [code=c++] #include <iostream> #include "node.h" #include "doublylinkedlist.h" using namespace std; int main() { system ("PAUSE"); return 0; } [/code] [B]node.h :[/B] [code=c++] class Node { public: Node *pointertonextnode;//pointer to the next node of type node Node *pointertopreviousnode;//pointer to the previous node of type node int nodedatamember;//a node's data memeber }; [/code] [B]doublylinkedlist.h :[/B] [code=c++] class doublylinkedlist { public: Node *pointertofrontoflist;//pointer to front of list Node *pointertobackoflist;//pointer to back of list //constructor to contruct a blank doubly linked list: doublylinkedlist() …

Member Avatar
Member Avatar
+0 forum 4

Hi, I have a web site. On index.php I have a HTML link to admin/admincp.php By simply adding a htaccess file to the directory 'admin', will the admin directory and it's contents be fully protected? I only want it to be possible for me to access mysite.com/admin/admincp.php, because I am the administrator and will be adding records to a mysql database through a HTML form in it.

Member Avatar
Member Avatar
+0 forum 3

Hi, I'm making a simple forum. When a user register's, I trying to create their join date. [code] CREATE TABLE Users ( userName varchar(15) NOT NULL, registrationDate datetime default NULL ) [/code] and then have MySQL automatically set that value: [code] $sql = "INSERT INTO Users (userName, registrationDate) VALUES ('".$username."' , '".NOW()."')"; [/code] The program keeps failing though. when the PHP code is ran it says: [QUOTE]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING[/QUOTE] Am I doing this right? I think it may be my syntax, but I could be wrong. Appreciate all help with this. :)

Member Avatar
Member Avatar
+0 forum 2

Hi, I have a linked list which stores base class pointers (which point to derived type objects). I'm trying to give this option to the user: [code=c++] cout << "Press 'n' then Enter to show next, 'p' then Enter for previous and 'q' then enter to return to menu" << endl; [/code] I tried to do it and wrote this: [code] case 'f': { i iter(listname.begin()); i beginning(listname.begin()); i end(listname.end()); string nextPreviousChoice = ""; do{ cout << "Press 'n' then Enter to show next, 'p' then Enter for previous and 'q' then enter to return to menu" << endl; getline …

Member Avatar
+0 forum 0

Hi, I have a program, which uses a vector to store some pointers. The program works fine. I'm trying to convert it to use a doubly linked list now though. At the top of the program I changed: [code] vector<Diary *>vectorname; [/code] to [code] #include <list> list<Diary *>vectorname; list<Diary*>::iterator i = vectorname.begin(); [/code] Later on in the program I access an element of the (former) vector using: [code] if(vectorname[a]->getName() == leadToDelete) [/code] And use: [code] if(advance(i,a)->getName() == leadToDelete) { //do something } [/code] instead. BUt when I try it fails to compile, saying: [quote] error C2227: left of '->getName' must …

Member Avatar
Member Avatar
+0 forum 3

Hi, I would like to display an RSS feed from a website on my website, but I want to hand code a solution rather than use a widget. Basically this is a learning task I have set myself. My question is how can I load the RSS feeds into a 'variable'. I want to then use XSLT to convert the feed into HTML. I have found the [URL="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.aspx"]XmlDataSource Class[/URL], but does this only work with IE? I need to work across all the common browsers on a Linux server. Thanks for any advice on achieving this. It's most appreciated!

Member Avatar
Member Avatar
+0 forum 3

Hi, I've been learning C++ these last few months, but never tried to make a GUI before. I've wrote a program in C++ which works via the command line, but now I'm trying to create a GUI for it (MFC using Visual Studio 2005, XP host). When I add an Edit Box to the form, then add a variable to the Edit Box, it's automatically creates a variable of type Cstring. In my program I'm using strings (#include <string>). Is there any problem with me simply adding the #include for strings and altering the code from CString to string? This …

Member Avatar
Member Avatar
+0 forum 2

Sorry, unable to delete threads.

Member Avatar
+0 forum 0

Hi, I have wrote a program which stores values in a .csv file. He is the how the data is stored in the .csv file: [quote] "Steve","21 Main Street, Nottingham","SW1 1AB","0115 9123456","These are some details. and, so.","112233","1359" "David Baner","123 Shaw street, Nottingham","NG92HJ","020 123456","ifbiugbuige","112233","1200" [/quote] Each line forms a single object. What I want to do is retrieve the values from the .csv file, so that I can recreate the objects again, but after reading Google, find myself a little lost in how go about this as simply as possible. So i was thinking of something like this: [code=c++] cout << …

Member Avatar
Member Avatar
+0 forum 5

Hi, I was wondering why the CREATE TABLE query in my code seems to be called automatically, whilst in the example below from w3schools, there is a line which explicitly calls the CREATE TABLE query. Why is that the query in the w3schools example isn't ran twice? My code: [code=php] <?php $connectionname = mysql_connect("localhost","XXX","XXX"); if (!$connectionname) { die('Could not connect: ' . mysql_error()); } // Create table mysql_select_db("databasename", $connectionname); $sqlcommandvariable = " CREATE TABLE Userssss ( userID int(8), userName varchar(15), firstName varchar(15), lastName varchar(15), password varchar(32) ) "; if (!mysql_query("$sqlcommandvariable")) die(mysql_error()); else { echo "success in table creation."; } mysql_close($connectionname); …

Member Avatar
Member Avatar
+0 forum 4

Hi, I have a question. Using the following code: [code=c++] #include <iostream> int main() { std::string s1; std::cout << s1.capacity() << std::endl; system ("PAUSE"); return 0; } [/code] In Ubuntu/KDevelop the output is 0. In Windows/V.Studio the output is 15. Can anyone suggest why it happens? I'm somewhat stumped by it's occurrence. Thanks very much, much appreciated.

Member Avatar
Member Avatar
+0 forum 2

I have a task to do about the std::string datatype. To do the task I need to Use KDevelop and be able to find the size of the buffer being used when performing operations upon strings, but never having used KDevelop before, I'm at a complete loss. Could anyone be so kind as to give me some direction as how to go about viewing a buffer which is in use? Can it's contents be viewed within a window of the IDE, or would I have to call functions to 'cout' details about the buffer being used? I'm at a complete …

Member Avatar
Member Avatar
+0 forum 1

Hi there, I was hoping for some advice on how best to solve my problem. I'm creating a .csv file to store objects in, but the datamembers which are strings, require the ability to have commas within the strings. I have found out that I therefore need to enclose the fields in the .csv file within double quotes. So I am trying to write a function to add double quotes to the beginning and the end of each string. This is what I have come up with so far: I have enclosed the relevant parts with comments like this: //XXXXXXXXXXXXXXXXX …

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm storing base class pointers in a vector, the pointers are pointing to objects from the derived class ( Leads ). I'm unable to access the 'getter' functions of the derived class. How can this be done? I'm trying to save the derived objects in a text file (database.txt) when the users chooses to exit the program, but my IDE (Visual Studio) is reporting: [QUOTE] error C2039: 'getDate' : is not a member of 'Diary' [/QUOTE] Here is my code : [B]Header file (diary.h) :[/B] [code=c++] using namespace std; #include <string> class Diary { public: Diary(string mainname, string mainaddress, …

Member Avatar
Member Avatar
+0 forum 6

Hi, I have been building objects on the stack using the following constructor: [CODE=c++] classname node(arg1, arg2); [/CODE] Which worked fine. But have now learned it is the heap I need to use. So I need to use the [B]new[/B] command I believe, but my syntax is wrong: [CODE=c++] classname *ptr = new node(arg1, arg2); [/CODE] But when I try this, it fails to compile. Can you help? Many thanks !

Member Avatar
Member Avatar
+0 forum 1

The End.