537 Posted Topics
Re: [code] #include iostream using namespace std; main() { cout << "Q: How many hookers does it take to screw in a light bulb?"; cout << "\nA: Go ask your mom."; return 0; }[/code] | |
Re: The best way to solve this would be to uninstall your compiler and turn off your computer. Leave it off for as long as possible for best results. | |
Re: Obviously, the only solution is to learn Chinese. or show us your code. | |
Re: I would probably recommend the use of the [URL="http://curl.haxx.se/libcurl/"]curl library[/URL] as way for your program to interface with the internet. As far as multithreading goes.. it may be possible to open web pages on demand from the user as the user initiates the action; therefore, I would explore the possibility … | |
Re: 1. try opening the file in binary and see if you still experience the same type of behavior 2. without seeing your code, i am not sure what you are using.. but you may have problems with these ascii values exceeding the 8bit capacity of the char data type. the … | |
Re: Any luck with that error? The only thing I can recommend at this point, is if you do get this thing to compile, I want you to do two things: 1. click on the .exe and drag it to the recycle bin 2. release the mouse button You may also … | |
Re: Probably the most efficient method that I could think of (in terms of line of code) would probably be something like this: [CODE] #include<algorithm> #include<cstring> char line[] = "Dance, too much booty in the pants."; int size = strlen(line); replace(&line[0], &line[size], ' ', '_'); [/code] [URL="http://www.cplusplus.com/reference/algorithm/replace/"] replace() from <algorithm>[/URL] | |
Re: Many have recommended the [URL="http://developers.curl.com/userdocs/CurlDocs.htm"]curl library[/URL] for applications that need to interface with the net. | |
Re: I use whatever works... I've spent hours looking for a compiler that could handle one single line of code before. You never know what comes with what compiler. Nothing works for everything. | |
Re: Get number (in binary) and enter into a string: [CODE] string binary; cout << "Enter a binary number: "; cin >> binary; [/CODE] Turn a binary number into a real number: [CODE] #include<algorithm> unsigned int number = 0; int exp = 0; //I think most people read binary right-to-left //the … ![]() | |
Re: we almost made it half way through step #1, until we ran into a rather significant problem: [CODE] this my assignment.. 1. Make a C program [/CODE] Fyi: you are in a C++ forum. | |
Re: I think the major extent of your problem takes place at lines #26 thru 28. [URL="http://www.cplusplus.com/reference/iostream/fstream/"]The <fstream> class[/URL] does not include an overloaded assignment operator. I believe the only operators overloaded for this class are the << insertion, >> extraction, and ! 'not' operators. Everything else (including the = assignment … | |
Re: Firstly, your evaluations of boolean expressions are incorrect. Rule of thumb: boolean logic is handled per expression, or as a stand-alone TRUE/FALSE flag. In your loop condition, you are trying to handle everything at once. It is important that each individual expression be able to resolve to true or false. … | |
Re: You are in charge of a high profile software design consulting firm. A customer bursts through the front door, comes running in flailing his arms wildly about, stops at your cubicle, looks you square in the eye and makes the following demand: [quote] the ocean file has to be made … | |
Re: What you have there appears to be the makings of 3 functions: parallel(), gauss(), and barrier(). The code does not adhere to the proper format of a c++ function. Additionally, the functions are not associated with any main() driver or WinMain() entry point. What you have there appears to be … | |
| |
Re: In line #20 you declare a single object of type 'Employee' In line #33 you attempt to dereferrence e using subscripts.. on your single 'Employee' object. In lne #35 you again attempt to dereferrence your single e object using array subscripts. You do not actually create an array of 'Employees' … | |
Re: Sooooooo...... do you need help with anything......? | |
Re: 1. create an ifstream object for file reading 2. Attempt to open the file 3. Perform error checking to see if file opened 4. If open successful, read file into a data structure of your choice (string seems to be popular) 5. close the ifstream object 6. Alter the data … | |
I thought this website on coding conventions was pretty cool.. learned some things that I never knew before: [url]http://www.possibility.com/Cpp/CppCodingStandard.html#init[/url] I was just wondering: If there are any conventions in particular you agree or disagree with (and why) If this would be worthy of being a 'sticky post' as I think … | |
Re: [quote]This does give me numbers, but not distinct. Thanks! [/quote] [quote]dis·tinct (d-stngkt) adj. 1. Readily distinguishable from all others; discrete: on two distinct occasions. 2. Easily perceived by the senses or intellect; clear: a distinct flavor. 3. Clearly defined; unquestionable: at a distinct disadvantage. 4. Very likely; probable: There is … | |
Re: In order to get done what you want done, you'd have to make an array of pointers... [CODE] //This will result in the 'const char' that you are trying to avoid char strs[numStrs][maxLength]; //Try this: //Dynamically allocated 2d array char** strs = new char*[numStrs]; for(int i=0; i<numStrs; i++) strs[i] = … | |
Re: Your code looked pretty good, and just glancing over your code, I was kinda stumpted at first, but I think I might have a possible solution for ye'... I believe that your .dat files contain a bunch of stuff. You read in the files succesfully without incident. I believe the … | |
Re: Help me, help you... [url]http://catb.org/~esr/faqs/smart-questions.html[/url] | |
Re: Here is probably the best tutorial you will ever get on binary search trees. I recommend you become very familiar with this if you plan to have any success with your homework: [url]http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx[/url] | |
Re: I think that it is important that we focus on the origins of pig latin and how it is properly implemented: [quote] Pig Latin is a language game of alterations played in English. To form the Pig Latin form of an English word the initial consonant sound is transposed to … | |
Re: #define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGABRT 6 /* abort() */ #if defined(_POSIX_C_SOURCE) #define SIGPOLL … | |
Re: I think getting down with binary trees is an exellent skill to have: [url]http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx[/url] | |
Re: [quote] when i run the program it display nothing.n no files by dat name is shown in that folder [/quote] I'm sure you've tested the fail bit indicators of your 'ofstream' object after your attempt to open() the destination folder and found that there were no errors. So I can … | |
Re: Here is an article explaining CALLBACK functions (good article I actually learned a lot) [url]http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557/[/url] Chapter #3 in Petzold's, "Programming Windows 5th Edition" explains a lot about windows creation and message handling. According to Petzold (p. 62): [quote] A window's procedure is always defined like this: [code] LRESULT CALLBACK WndProc(HWND … | |
Re: I think the problem is here: [CODE] void getAverage (int FoodForMonkey[][days]) { for (int col=0; col < days; col++) { float numTotal=0; cout << "Average amount eaten on day " << col+1; for (int row=0; row < monkey; row++) { //Since you are calculating a daily average, //you should clear … | |
Re: I think I remember some construct of the windows api that allows one to enumerate system devices.... Allow me to break into the windows bible and I'll get back to you on this... [edit] As I am doing more research on this topic, I did find this forum post you … | |
Re: Your file contains one single line. You are making at least 3 calls to getline()... and then making 2 extraction operations after that. getline() will return a single line from your file. your file only contains one line. I would recommend either making one call to getline() (which will read … | |
Re: After assigning a player move to the game_grid[][], in order to display the newly updated board, just use a nested loop to walk through your array, displaying all elements to the screen: [CODE] void display(int board[][]) { //Display all contents of the array for(int i=0; i<3; i++) for(int j=0; j<3; … | |
Re: [quote]I have seen an array struct in C that can hold data even if they are a different type.[/quote] This would be my best guess... but I'm open for suggestions: [CODE] void* array[4] = {5, 'Q', 2.7, 3.14159}; int* i = array; char* c = array; double* d = array; … | |
Re: Is there any specific piece of code you are looking at that is peaking your interest.. causing you to ask these questions? If so, please show us. It will help us to explain it to you if we actually have something to look at. | |
Re: The problem with your program is in it's design. Here you throw everything inside of a huge loop... and yes, since you are testing eof() which is highly unrecommended, the loop will make at least 2 iterations: [CODE] ifstream myfile("BankData.txt"); if (myfile.is_open()) { while (!myfile.eof()) { myfile>>loginName; myfile>>password; if(loginName == … | |
Re: The block of code you just provided us appears that it would work as desired. Use of eof() is discouraged, but I don't see it as a major problem here. You originally threw over 600 lines of code at us with a "Help me it doesn't work" type of request. … | |
Re: [CODE] #include<fstream> #include<cstring> #include<string> #include<algorithm> int line_counter = 0; int word_counter = 0; int punct_counter = 0; int size = 0; ifstream infile; string line; while(getline(infile, line)) { line_counter++; size = line.size(); word_counter = count(&line[0], &line[size], ' '); word_counter++; for(int i=0; i<size; i++) { if(ispunct(line[i])) { punct_counter++; } } }[/CODE] | |
Re: [quote]How can I keep that from happening? [/quote] Fill them up with stuff. | |
Re: [quote]Could it be possible for me to read the file name as a string, and add the extension ".output" to the string, and then convert it back to an array of chars?[/quote] I'm glad you mentioned this. String class objects are very versitle and can handle virtually any input the … | |
Re: [quote]//This is where I want to access p but don't know how.[/quote] The variable named 'p' does not exist anywhere within the scope of your Reposition() function. Either pass it in from elsewhere or declare a local var named 'p'.. if this is what you desire. So far, a variable … | |
Re: [quote]can anyone help me convert this code from array to Vector?[/quote] I will help you. [LIST=1] [*]Instead of declaring an array, declare a vector. [*]Anytime you want to add to the vector, call the push_back() member: [CODE=iline]myvector.push_back(input);[/CODE] [*]Anytime you want to get stuff from the vector, you can use subscripts … | |
Re: I'll make a deal with you.. put code tags around your code, and I will solve your problem for you. I'll even take out the math.. which is the most complex I have seen for a coin flippin' game. | |
Re: You may want to check [URL="http://www.youtube.com/watch?v=aGx576RYib8"][B]this[/B][/URL] out before posting homework. | |
Re: [code] #include <iostream> #include <string> #include <sstream> using namespace std; int main () { string mystr; double price=0; double pay = 0; int quantity=0; cout << "Enter price: "; getline (cin,mystr); stringstream(mystr) >> price; cout << "Enter quantity: "; getline (cin,mystr); stringstream(mystr) >> quantity; cout << "Total price: " << … | |
Re: Why are you trying to access a second element, in a 1 element vector? Unless I am missing something.. [CODE] //I think this... if(kompjuteri.getNaziv(i) == comp_name){ racunala.erase(racunala.begin()+i);} //Should be this: if(racunala[i].naziv == comp_name){ racunala.erase(racunala.begin()+i);} [/CODE] | |
Re: You will probably want to take some time one day and study the [url]http://www.winprog.org/tutorial/bitmaps.html[/url]. Also, since you are operating in a DOS console environment, be sure to check out adrianwx's [URL="http://www.adrianxw.dk/SoftwareSite/index.html"]windows programming for DOS tutorial[/URL]. Although I am not sure if one can load a bitmap to a dos console … | |
Re: [quote]i have here a standard visual c++ function that clears the screen[/quote] Be rest assured, this is not standard c++. What this is though, is a group of functions derived from <windows.h> called the "windows advanced programming interface" or [I]API[/I]. The window.h library contains thousands of functions that allow you … |
The End.