565 Posted Topics
Re: [Take a look at this.](http://lmgtfy.com/?q=c%2B%2B+game+of+dice+-+do+my+homework%3F) Btw, searching on google makes your life easier (an ours also). http://www.cplusplus.com/forum/beginner/65998/ Try learning from others mistakes, understand the concept, than try to programm your homework. | |
Re: The problem here is that you don't have any condition to actually break the loop. Try for example, as an else if command to exit the loop. else if (anotherDay=="q"){ break; } This code, if you put it just above the > else > cout<< "not a valid day. "<<endl; … | |
![]() | Re: There must be something related to memory allocation or space in your array. The > Unhandled exception at 0x77c415de shows you that you have mistreated some memory allocation. Frankly I didn't look up closly over your code, but in most cases there are problems with either allocating space in the … ![]() |
Re: if you're trying to return the size you can do it like this: int size(){ return (vector.size()); } or like this: int size1(){ return ((int)vector.size()); } and if you want to use it in a "for", like this: for (int i=0;i<(int)vector.size();i++){ //do stuff } for (int i=0;i<(int)size();i++){ //do stuff } … | |
Re: this might help you: http://www.somacon.com/p125.php The & is binary bitwise AND. Read the whole link and you'll figure it out. | |
Re: I wouldn't call this thread: Some basic C++ questions about processes, because it's related to UNIX and C. In UNIX C is the language in which you use and program helped by the system, and not in C++. Here, read this http://beej.us/guide/bgipc/output/html/multipage/fork.html It's really usefull and explains really good. And … | |
Re: I would suggest a double condition "?" operation at > Buffer[I] = (NewValue[I] != '\n') ? NewValue[I] : '\0'; Here's an example of what I'm trying to say: int main(){ string a; for (;;){ cout<<"> "; cin>>a; if (a=="q"){ exit(0); } string b=(a=="b" || a=="B") ? (a=="b" ? "b":"B") :"somethign … | |
Re: This might help you [Minimax Wikipedia](http://en.wikipedia.org/wiki/Minimax) | |
Re: > I figured out my issue. It had to do with the form that I was selecting I would advise you if the problem had been solved, or you yourself resolved the isue to mark the thread as solved, in order for others who seek problems to solve not to … | |
![]() | Re: This website is really complete about tkinter. It might be usefull: [An Introduction to Tkinter](http://www.pythonware.com/library/tkinter/introduction/index.htm). I used to use this when I was dealing with Tkinter. > self._text_entry = Entry(self._text_frame, text="") > self._text_entry.bind("<Key-Return>", self._text_save) An example of binding. [Direct link to the bindings from the Tkinter tutorial.](http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm) |
Re: I've looked over your code and as deceptikon said, it works fine. Tested on win 7 ultimate on x64 with MinGW and gcc 4.6.1, thus the error lies somewhere else. I would suggest thou changing the operator< function to this: bool operator<(const RAngle& rhs)const { return (l<rhs.l); } This will … | |
Re: Indeed. @ line 20 > delete cfg; will delete the 1st time when it gets there, but there can be multiple times when that line is accessed, so in further accesses it will crash the program, not knowing what to delete. | |
Re: If you have trouble with your while loop, try with the for one: Here's a quick example. #include <iostream> #include <string> using namespace std; int main(){ for (string a;a!="y";){ //the for exits only when "y" is typed. cout<<"> "; cin>>a; if (a=="1" or a=="1."){ // if you type "1" or … | |
Re: Do you want a string-based menu interface for console, or you just want to make something out of the ASCII and the `switch() {case:''}` methods? I found that the bug in your program lies on the lines 24-25. The switch case, when 'w' is pressed it's ok, the score will … | |
Re: #include <string> #include <iostream> using namespace std; struct pieces { string ap, bp, cp, dp, ep, fp, gp, hp, ip, jp, lr, rr, lk, rk, lb, rb, q, k; } b, w; int main(){ b.ap="Hello"; w.ap=" world.\n"; cout<<b.ap<<w.ap; } /* * Output: * Hello world. */ I can't see where … | |
Re: You must use the `getline` method. Here's an easy example: #include <iostream> #include <string> using namespace std; int main(){ string answer; cout<<"> "; getline(cin, answer); cin.ignore(); cout<<"I have just inserted: "<<answer<<endl; return (0); } The `getline(cin, answer);` will take whatever you insert, even the spaces, till the `ENTER` signal is … | |
Re: Depeinding on your OS: if you do work in UNIX, it is possible by a C-signal handle function. #include <signal.h> #include <stdlib.h> void handler(int sig){ printf("Received signal %d and now I'm exiting.", sig); // or cout. exit(0); } int main(){ signal(SIGINT, handler); //do stuff; return (0); } But this is … | |
Re: Why don't you use like this: #include <iostream> #include <string> using namespace std; int main(){ int repeat = 2; string answer; while (repeat != 0){ cout << "Insert yes or no: " << endl; cin>>answer; if (answer == "no" or answer == "No" or answer == "NO"){ repeat--; } if … | |
Re: I would suggest also PHP, 'cose its syntax derivate from C, and C++ syntax also. > Influenced by C, C++, Java, Perl, Tcl > Implementation language C Got them outa Wikipedia. | |
Re: thou, I don't really see where's the problem? > Number of lines,words,letters is : 14 15 128 > > please someone help me to output of the code as > Number of lines,words,letters is : 14 15 128 Isn't this the given output? | |
Re: Remove the endl after the cout expresion inside the for. The `for` statement will print out i and the new line every time it pharshes through the conditions. Use like: for (int i=0;i<n;i++) cout<<i<<" "; cout<<"\n"; // or cout<<endl; or as Schol-R-LEA stated, if you don't want the extra space: … | |
Re: You should definately post a little more about your situation? You can simply do like this: //Pseudocode. //1st suggestion: Login(){ return (retrive_previous_id()); } SetLogIn(){ this->id=Login(); } InsertInfo(); Logout(){ //increment id. set_previous_id(id++); } // 2nd suggestion: Login(){ return (retrive_previous_id()); } SetLogIn(){ //here you increment the id. this->id=Login()+1; } InsertInfo(); Logout(){ set_previous_id(id); … | |
Re: void encode(string str) { char * ccode = new char [str.size()+1], * ncode = new char [str.size()+1]; int str_size = str.size()+1; strcpy (ccode, str.c_str()); for (int i=0; i!=str_size; i++) { if (ccode[i]=='t') { ncode[i]='p'; } cout << ncode; } delete ccode, ncode; } | |
Re: So, what you're saying is that we should "darken" the world a bit? | |
Re: In your program the <iostream> is spelled wrong, but as I can now see, it was already covered by some1 else, and the .h is depreciated in the C++ language nowdays. | |
Re: > Really? What makes you think so? > > You waited 1-1/2 years to make your first post with this newsworthy information??? best wait ever. By looking over your assignment, and what have you accomplish so far, I'd say that you need to get on working. The best way to … | |
Have some problems with the qt destructor. I'm working on QtCreator: here's the class: the .cpp #include "controller.h" Controller::Controller() { } Controller::Controller(MovieRepo *movrep, MovieValidator *movval){ this->movrep=movrep; this->movval=movval; } void Controller::addMov(int id, string title, string desc, string type)throw(ValidatorException){ Movie* mov=new Movie(id, title, desc, type); movval->validate(*mov); movrep->store(*mov); } const Movie* Controller::getById(int id){ … | |
Re: Depending on your tastes, steak can be liked by some or hated by others, but in generally, I don't mind. Do you believe in God? | |
Re: I hope this will help you, and I added some explanations along the source code. /* * count.cpp * count.cpp is licensed under GNU GENERAL PUBLIC LICENSE * Created on: May 15, 2012 * Author: sin */ #include <string> #include <iostream> #include <sstream> using namespace std; int main(){ stringstream lettersfound, … | |
I have this function: void read(){ int id; string desc; string title, type; cout<<"Movie's id: "; cin>>id; cout<<"Movie's title: "; cin>>title; cout<<"Movie's description: "; getline(cin, desc, '\n'); cout<<"Movie's type: "; cin>>type; cout<<"You have typed in: " <<id <<" " <<title <<" " <<desc <<" " <<type <<".\n"; } and my … | |
Re: I'm not a pro in this domain, but I will tell you my opinion. Regardless the fact that the startup is really really slow, it may be due to the fact that your code must be improoved to handle large arguments. As you said, it happens only when dealing with … | |
Re: Try to put this includes: > #include <iostream> > #include <string> > #include <vector> > #include "Student.h" after this ones in your .h files: > #ifndef COURSE_H > #define COURSE_H | |
OK, so here's the deal. I'm trying to create 2 programs, a server and a client, which communicates between them. I'm working on Ubuntu, throughout FIFO. So, 1st of all, I create 2 FIFO's: $ mkfifo pipe $ mkfifo pipo Ok, and after that I create the client and the … | |
Re: If you have like this: a = 2.2 b = 1.4 c = 2.7 d = 3.5 e = 42.8 one easy way is to simple create the list: l=[a, b, c, d, e] print l '''output: [2.2, 1.4, 2.7, 3.5, 42.8]''' | |
I was wandering what could be the causes of this error message? Like in general. `\\: *stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation fault",frame={addr="0x00402d53",func="Domain::Movie::show",args=[{name="this",value="0x1"}],file="..\\src\\Domain\\Movie.cpp",fullname="e:\\eclipse for c++\\workspace\\lb6-8oop\\src\\domain\\Movie.cpp",line="36"},thread-id="1",stopped-threads="all"` 10x. | |
Re: I would suggest the Qt GUI tools, if you're working on Eclipse, with the Qt eclipse integration plugin. Here, this might help you: [Lecture 7: QT.](http://www.cs.ubbcluj.ro/~istvanc/oop/lectures/Lecture7.pdf) | |
Hi. So my problem is that I can't save into a vector throughout a function, but I can save directly in the vector. /* * asd.cpp * asd.cpp is licensed under GNU GENERAL PUBLIC LICENSE * Created on: May 3, 2012 * Author: sin */ #include <iostream> #include <string> #include … | |
Re: Well, when you get some errors like this: 1>i:\year 2\graphics programming\mloader\main.cpp(318) : error C2059: syntax error : ']' 1>i:\year 2\graphics programming\mloader\main.cpp(318) : error C2143: syntax error : missing ';' before '{' 1>i:\year 2\graphics programming\mloader\main.cpp(318) : error C2143: syntax error : missing ';' before '}' you have missplaced in your program … | |
Re: Here are some useful links for you: [URL="http://www.cplusplus.com/doc/tutorial/classes/"]http://www.cplusplus.com/doc/tutorial/classes/[/URL] [URL="http://www.cplusplus.com/doc/tutorial/classes2/"]http://www.cplusplus.com/doc/tutorial/classes2/[/URL] I suggest you take the advice of VernonDozier, if you don't know much about classes. Standard documentations are useful in such situations. | |
Re: Have you searched on google for that? [URL="http://www.wxpython.org/docs/api/wx.MouseEvent-class.html"]http://www.wxpython.org/docs/api/wx.MouseEvent-class.html[/URL] [URL="http://wiki.wxpython.org/How%20to%20Learn%20wxPython"]http://wiki.wxpython.org/How%20to%20Learn%20wxPython[/URL] Duno, but I guess it will help you - topics related to WxPython... | |
Re: Hi roe1and. I've look upon your assignment and I've came up with this. It's not much, but I hope it will help you. Note that you would need the same amount of constants 'a', 'b', 'c' from your source file in order for this to work. [code]''' Created on Feb … | |
Re: If you're on 3.x version of Python, then you'd have to have the print function as a function, meaning print (" "), but clearly that's not the case having the NameError error: [code]NameError: name 'dinesh' is not defined[/code] and the simple print statement: [code]print "%s dinesh" %l[/code] Well all of … | |
Re: Well, apparently, this approach of classes may cause some inconvenients due to the fact that it's not the brightest approach. Try to define some functions which will print that things for you, from inside the class, use some functions to add elements to the class, then, in the main function, … | |
Re: I don't know if I should post this here, but here's a code snippet from a game I made, some time ago, while reading the book of Al Sweigart, Invent your own computer games with Python (and I recommend this book if you want to do such games - and … | |
Re: So, is there any way we can ensure our safety, and if so, find out this Trojan, and delete it, cleaning our system? | |
Re: [CODE]from __future__ import division print 32/10 """ My output: 3.2 """[/CODE] Basically, the [COLOR="purple"]from __future__ import[/COLOR] division, will convert the [b]/[/b] operator into the [COLOR="Red"]floor division operator[/COLOR], which will do the exact division. Note that if you do such thing, the [b]/[/b] operator which was before, meaning 32/10=[3], the real … | |
Hi. I've seen that it's a custom here to present yourself if you are new to Daniweb. Well, this is my laime attempt on doing such: [b]Name[/b]: Lucaci Andrew [b]Age[/b]: 19 [b]Primary role[/b]: Currently, I'm a student of Babeş-Bolyai University Faculty of Mathematics and Computer Science, from Cluj-Napoca, Romania. [b]Main … | |
Re: You want to print as a matrix, or such? [code] # A simple matrix # This matrix is a list of lists # Column and row numbers start with 1 class Matrix(object): def __init__(self, cols, rows): self.cols = cols self.rows = rows # ;;initialize matrix and fill with&nbsp;zeroes self.matrix = … | |
So, what is my deal... I'm working on a script, which, at some point will require the user to insert his or hers username and a password. My question is, how can I make that when the user will write in the password box/line whatever, instead of its characters, to … | |
I keep getting this error and i don't understand why. [code]Traceback (most recent call last): File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 105, in <module> fr_runt() File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 95, in fr_runt run.run() File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 58, in run self.data.write(file, key, value) File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 23, in write fh = … |
The End.