447 Posted Topics
Re: Maybe something like:[code=cpp]nodo *p1, *p2; p1 = List; p2 = List->next; if ( p1->key == p2->key ) // or p1->key == p1->next->key // do this...[/code]Your problem is that you don't have a random access element for your list, i.e. the [] operator. You could probably write that if you wanted. | |
Re: I think what you're looking for is [URL="http://www.cplusplus.com/reference/stl/set/erase.html"]erase[/URL]. | |
Re: A loop's a loop. It doesn't matter how you do it. It's entirely equivalent. No matter which you choose all should produce the same five-time iteration that you want. I'd use [inlinecode]for[/inlinecode] but a [inlinecode]while[/inlinecode] would work too. | |
Re: Fingers. If you want to vote for someone you cut off your finger and put it in a box. Most fingers wins. It'll mean only people who REALLY want a candidate will vote so you get the best government. | |
Re: One problem. [inlinecode]scanf("%d",&kilowatt);[/inlinecode] kilowatt isn't an integer. Change the format specifier to what you'd use for a float. Is this right? [inlinecode](kilowatt-15)*20+(10)+compute_tax(total);[/inlinecode] Haven't looked at it, just seems odd that you're taking 15 from kW. Is this right? [inlinecode]totalwtax=total+tax;[/inlinecode] Should it be * not +? | |
Re: For dynamic arrays first forget anything about uppercasing for the moment and read about the [URL="http://www.cplusplus.com/doc/tutorial/dynamic.html"]new and delete[/URL] keywords. This is how C++ dynamically allocates memory. So after you're familiar with this read an (unsigned) integer via [inlinecode]cin[/inlinecode]. Use [inlinecode]new[/inlinecode] to allocate the array of the size the integer specifies. … | |
Re: >> Quite possibly, it is simply another form of matter.. An anti-matter I don't think so. I remember being fascinated about what my physics teacher (don't judge him because of the gravity definition he gave us, media player thread), said about what would happen if matter man and an anti-matter … | |
Re: I did something similar to this before and I found the best way to do it was to create a packet structure... something like:[code=C]struct packet_structure { char preamble; char length; char from; char to; // ... etc };[/code]I found it a lot more accessable that way. Do you have to … | |
Re: Doesn't hang for me. What OS and compiler are you using? | |
Re: In my opinion without some careful management it's asking for trouble. Why do you have to open it? Couldn't you do something like...[code=c++]std::[i/o]fstream fstr; // ... fstr.open( "file_name" ); do_recurs_function( fstr, /*other params*? ); fstr.close();[/code] I had a similar situation where I was opening and closing streams (to different files … | |
Re: Try, at least. Then come back with an attempt and we'll help from there. We'll explain your mistakes, suggest how to fix and then you'll have a working solution. | |
Re: This is more of a "Here's my problem. I've tried this but it doesn't work, please help" site rather than a "be my friend and fix my problem site". Explain the problem here and you'll likely get a response. | |
Re: To understand the reasoning of this execute the following:[code]int main() { std::cout<< sizeof( unsigned long) << ", " << sizeof( unsigned short ) ; return 0; }[/code]Basically short*short = short, but you're comparing this to a long. So there's a size mismatch. YOu could cast the shorts if you want … | |
Re: Heh. In between. Normally people say 'from'. I was going to ask you what system you're using but [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044654269&id=1043284392"]this[/URL] solution, I think, covers most of 'em. | |
Re: Obviously not comprehensive (cause of unheard-coverups), but here's a longish list (I like lists): [url]http://en.wikipedia.org/wiki/List_of_UFO_sightings[/url] You're one's mentioned at the end, Josh: [QUOTE]Dozens of residents of Stephenville claim to have seen a "large silent object with bright lights flying low and fast." Several also reported having observed fighter jets chasing … | |
Re: I'd use the modulus operator and the division operator in a loop, something like: [code]do { knum += num%10; } while ( num/=10 );[/code] | |
Re: So a number is taken from a user, and 2 is subtracted from it until it's 0? Why do you have an array or a[100]? Do you need to save each number? Just try to think about it. Problem:[LIST=1] [*]You're given a number. [*]You take two from [I]this[/I] number, [*]you … | |
Re: [code=cpp]#include <iostream> #include <vector> int main( void ) { // 4x5 (4 in x, 5 in y) array, containing -1 std::vector< std::vector<int> > vvint( 5, std::vector<int>( 4, -1 ) ); for( int j=0; j<vvint.size(); j++ ) { for ( int i=0; i<vvint.at(0).size(); i++ ) { std::cout<< vvint[j][i] << " "; … | |
Re: What time do you want it on your desk for? I've never had to do this, but did a quick Google search and got this -- [url]http://support.microsoft.com/kb/243953[/url] Looks about right, works too. | |
Re: Does this problem recur every time of just for control panel or security centre? This probably isn't the best place to get answers for your problem, aftommy, maybe try the windows forums -- [url]http://www.daniweb.com/forums/forum99.html[/url] You'll probably find the best help in the correct forum. | |
Re: On the contrary - best remake ever - Jimi eat world - Firestarter :) I don't like them normally, but I love that song. | |
Re: I dunno... babies sleep for like 12 hours a day. My nephew's like 1 sleeps from 8PM to 7AM with a nap for an hour or so. | |
Re: In this order (ordered by difficulty of problem to be tackled) -- do nothing out of ordinary, music, tea, coffee, beer, Irish coffee, straight whiskey. Normally do a linear iteration through the set and stop when the relaxing method meets the challenge. | |
Re: I like this topic. Wasn't it Einstein who said "You don't understand something fully unless you can explain it to your grandparents"? I'm nearly sure I'm mixing quotes, but I stand by it. | |
Re: So it'll say like 13 and you want to grab the next 13 characters? Will the length actually be wrapped in []? If ya have boost installed use boost::regex for the simplest way. You might be able to use strtok to split them all with respect to [, skip till … | |
Re: I had an amusing one today. I'm writing a SMS sending program. It's a remake of a program I wrote ages ago for the same purpose, but the wobsite to which the program interfaces changed its layout so I had to change my program. Anyhow, cookies are now used by … | |
Re: Alpha and omega. Beginning and end. All I can say is thank Dani for the webpage preview. Saved a lot of time! | |
Re: Do it via a timer. In the message loop handle the timer event for repainting and repaint. | |
| |
Re: [code]//#include <fstream>[/code] | |
Re: I'd say 24 season one. The others were a bit too much for one man to handle in one day. But season one was good. Perfect day. | |
Re: Yeah. I seem to remember a headline along the lines of "State of the union undress", which I chuckled at. Peta.... people eating tasty animals, right? | |
Re: What exactly is that meant to establish? Are you seriously trying to start anything other than an argument? | |
Re: Try using regex in a program and tell us what happens! You'll need a regex library. There should be some freely available. Boost has one, right? | |
Re: You could always have them in an array and use [URL="http://www.cplusplus.com/reference/algorithm/min_element.html"]min_element[/URL] and max_[URL="http://www.cplusplus.com/reference/algorithm/max_element.html"]element[/URL] From site:[code=cpp]// min_element/max_element #include <iostream> #include <algorithm> using namespace std; // snip int main () { int myints[] = {3,7,2,5,6,4,9}; // using default comparison: cout << "The smallest element is " << *min_element(myints,myints+7) << endl; cout << … | |
Re: Alternatively, if you want to return something you could create a struct/class which contains the data you want to return. [code=cpp]#include <iostream> #include <string> #include <fstream> struct names { std::string first_name; std::string last_name; }; names read_from_file( std::ifstream &in ) { names i_names; in >> i_names.first_name >> i_names.last_name; return i_names; }[/code]Probably … | |
Re: Maybe try a: [code]void printMe const { // Code here... }[/code] | |
Re: Depends how you program. If you're programming a GUI, like with win32api or mfc maybe, it's a doddle. There's this for displaying a picture in dos - [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044665557&id=1043284392[/url] but I don't know if it works. | |
Re: Apparently a whole pile of [URL="http://www.myheritagefiles.com/K/storage/site1/files/67/23/92/672392_14989604512284fctyzs48.JPG"]chicks[/URL]... odd. | |
Re: >> (Havent ever heard of them Dude!? Where have you been. They're those old cynical fellahs. [url]http://en.wikipedia.org/wiki/Statler_and_Waldorf[/url] Animal :) He's that crazy drummer. Oh muppets. | |
Re: Why don't you show us what you have started and we'll go from there. If you have nothing started start and you'll be more likely to get help. | |
Re: Why do you need to cast or even make a and b? Just test num1 and num2:[code=cpp]using namespace std; int main() { while(1) { int num1, num2; cout << "Insert two numbers" << endl; cin >> num1 >> num2; if ( ( num1 <= -1 ) || ( num1 > … | |
Re: "He is an inspiration for many around the village" I suppose inspiration is all relative. | |
Re: >> Every generation thinks the up and coming generation is declining in morals. Precisely. And I don't think that it's really a moral issue. This current generation probably has more exposure to everything than any other previous generation -- with the internet, tv, etc. Sure not all of these things … | |
Re: A solution to what you desire is given pretty much straight away, but it makes an interesting read -- [url]http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx[/url] It's not, however, a question about srand. That merely 'seeds' rand. You want to get random numbers which is rand. |
The End.