279 Posted Topics
Re: vbapi is no longer supported. Your article actually says so, but not very clearly (just under the article title, to the left). Try [url=http://support.microsoft.com/kb/187912]this article[/url] instead. [url=http://support.microsoft.com/kb/205277]This one[/url] might be even newer/better. | |
Re: Here's a parital fix. I fixed a couple of problems (noted in comments), and a couple of stylistic things in your first two functions. I didn't even look at the other functions, but it works better. It seems to still be missing one name. [code] int main() { ifstream fin … | |
Re: OP> [b]How do i get it to parse the ":" and just leave the word sunny[/b] [code] /* This assumes there are no other colons or commas before the ones you want. */ char word[MAX_WORD]; char *pColon, *pComma; pColon = strchr (string, ':'); if (!pColon) { /* No colon found; … | |
Re: Your main problem is that you need to do the sscanf before you do the strtok(NULL,"..."). Couple other problems: no use passing in txt to use as local variable; return type doesn't match what you're trying to return; renamed a couple variables. And I changed sscanf to strcpy; but sscanf … | |
Re: Do you still get the error if you remove: * the file stuff? (replace it with a single buf load to tokenize) * the token stuff? Post a single file minimal version that recreates the error. | |
Re: You shouldn't really "BUMP" a post. At least pretend to ask another question! regex is something you can look up yourself, but it is not necessary for your problem. Here's an example of parsing a simple config file: [code] /* File config.txt: num = 123 str = hello flt = … | |
Re: You could be missing headers. But also, you need to use the c_str() member of a string to open a file. [code] #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string flight; cin >> flight; flight = flight + ".txt"; ofstream myfile; myfile.open (flight.c_str()); myfile … | |
Re: [QUOTE=unbeatable0;848183]Another thing is that string::search() returns string::npos if the search function does not find what it was told to find, and not -1[/QUOTE] This is an interesting point. I notice in the standard, clause 21.3 (Class template basic_string), paragraph 6, it does say that: [icode]static const size_type npos = -1;[/icode] … | |
Re: What does "written successively in the 15th line" mean? Do you mean starting at the 15th column? | |
Re: [icode]in.ignore()[/icode] is reading another character and ignoring it. Replace [icode]in.ignore();[/icode] with [icode]continue;[/icode] to "ignore" the current character in n. | |
Re: So you are wanting to read a board created by another program. You want to read a screen capture of it? How many different pieces in mahjong? If the pieces are different enough and there's not too many, you could probably figure out something simple. | |
Re: It should probably be: [code] STEP = CAR_VEC[i].PASSD.erase(STEP); [/code] | |
Re: Just put some spaces or tabs, that is, \t characters at the beginning of the menu lines. | |
Re: Try changing the relevant part of the rc file to this: [code] CONTROL "Eastern Time", IDC_EASTERN_SELECT, "button", BS_AUTORADIOBUTTON | WS_GROUP, 40, 80, 100, 8 CONTROL "UK Time", IDC_UK_SELECT, "button", BS_AUTORADIOBUTTON, 40, 100, 100, 8 CONTROL "HK Time", IDC_HK_SELECT, "button", BS_AUTORADIOBUTTON, 40, 120, 100, 8 [/code] Set the initial radio button … | |
Re: Your stack trace clearly shows the string allocator blowing up. But how is that possible? Sadly anything is possible with undefined behavior. You could zip your source and attach it. | |
Re: Code is not supposed to look like that. A single function should not span page after page. You've managed to produce structured spaghetti code, with meatballs. (I don't even know what that means.) :) Divide it up into more pieces. More objects, or at least more functions. If something seems … | |
Re: Four bad sorts: bubble sort insertion sort selection sort shell sort | |
Re: Here's a simple shuffle that ensures every element is moved at least once. Note the loop only needs 13 reps for 13 numbers. [code] const int MAX = 13; int a[MAX]; for (int i = 0; i < MAX; ++i) a[i] = i; for (int i = 0; i < … | |
Re: I believe you do in fact catch the exception as it is "going on". And since you can catch different exception types, you can tell which is which. Here's a simplified version of loadFile. More ... stringy. Less ... errory. [code] #include <iostream> #include <fstream> #include <string> #include <stdexcept> std::string … | |
Re: This is old school indeed: [code] int set_keysig (s, ks, init) char s[]; struct KEYSTR *ks; int init; { /* function body */ } [/code] Should be updated to: [code] int set_keysig (char s[], struct KEYSTR *ks, int init) { /* function body */ } [/code] Other than that (and … | |
Re: I suppose the canonical example is the example at the bottom of [url=http://msdn.microsoft.com/en-us/library/0wwk06hc.aspx]CWnd::OnCtlColor[/url] on MSDN. | |
Re: To set up a handful of records, perhaps for a little hard-coded testing, you can, of course, do this: [code] // Initializing first 3 fields of first 2 records singleIMEI a[30] = {{"00","01","02"}, {"10","11","12"}}; [/code] | |
Re: And you haven't said what the format of the line is. There are two common possibilities: a fixed-length format and a delimited format. A fixed-length is like this: name0---addr0---phone0---info0-----pay0--- name1---addr1---phone1---info1-----pay1--- name2---addr2---phone2---info2-----pay2--- (As long as you're only accessing it sequentially, the last field could actually be variable length since the end-of-line … | |
Re: sum must be initialized to zero. You don't need the variable add. | |
Re: [QUOTE=Ancient Dragon;844662]its a poorly written program. ... line.find() doesn't return -1, it returns string::npos.[/QUOTE] Yeah, it's a pretty rickety structure, I must admit. :( I suppose that's just another reason not to post "solutions" since the kind of thing you whip up in five minutes is likely to be error-prone … | |
Re: regexes can be worthwhile. | |
Re: What are you doing with words like [i]a, the, on, and, it[/i], etc. They would seem to contribute an inordinate amount to the score and yet nothing to a sentence's "importance". It's possible they just average out, I guess. Or maybe you could have an ignore list of the so-called … | |
Re: You kids and your string toking! Firstly, if your filename is actually "lines.txt" (as you say at the bottom of your post) then that's probably the filename you should use in your program. :) And you should test the stream like this: [icode] while (ins >> line)[/icode] | |
Re: I find it useful on occasion to place a prototype in a function. (pssssssssssss) | |
Re: > How else can they be different? Yep, they must be the same function. It works if you pick a specific copy like this: [icode] mycar.racer::cruise(50);[/icode] or this [icode] mycar.tank::cruise(50);[/icode] But "diamond inheritance" looks like something to avoid in general. Seems strange that the language wasn't designed to include only … ![]() | |
Re: I'm not a socket-head, but since no one has helped you yet, I'll point out a couple of things. If you want help from others, I suggest you give more detail about what it is doing wrong. This method of turning a number into a string will only work if … | |
Re: How much of your OS is finished? If you're asking about the GUI you must at least have finished the kernel and a command-line interface. Will your OS have virtual memory? Multitasking? Obviously it must have a file system. Are you writing the device drivers yourself, too? Quite a project … | |
![]() | Re: The "download" link somehow added backslashes before every single and double-quote. I notice that you have no increment of the iterator in write_out. Add a ++itr before the end-brace of the while-loop. If that doesn't fix the problem, can you be more specific? How would we recreate the problem? [edit] … ![]() |
Re: It would also be nice if it worked. Did you test it fully? Try entering an incorrect password followed by the correct password. Also, terminate and terminator are confusing names. How about triesUsername and triesPassword ? | |
Re: Your dream of [code] char string[15]; string = getstring(15); [/code] will not work. You either have to do this (and why not?) [code] getstring (string,15); [/code] Or this [code] char *string; string = getstring(); // getstring allocates string storage // use string free (string); [/code] | |
Re: In equal(), declare L1 and L2 as NODE*, not node. C does not generally support bool (use int). TRUE and FALSE need to be declared, or just use 1 and 0. (Or perhaps your version of C supports bool, in which case you mean true and false, not TRUE and … | |
Re: What exactly is wordCount counting? Aren't you passing it a single word? | |
Re: You're defining your array with a size of zero. (ARRAYSIZE is 0.) And even if you fix that, your code often refers to listitem[size], which is outside the array bounds. | |
Re: Try something like [url=http://msdn.microsoft.com/en-us/library/dd144938(VS.85).aspx]GetTextExtentPoint32[/url] or one of it's cousins. | |
Re: You need to use the prefix form of ++ and --. So: [icode]return( add( ++n, --m ) ) ;[/icode] | |
Re: What is _word_list ? What is isnotpuct ? What is wordCount() ? | |
Re: You do realize that you cannot use spaces. You must use tabs. | |
Re: "Please criticize my code." My favorite question! :) The biggest problem is that your variable names are too long. "Descriptive" does not mean "long". Here are some better names: [code] mathematicalOperation expr (or expression, if you must) operatorSign oper (or operation) getFirstDigitIndex iDigit operatorSignIndex iSign firstNumber strNum1 notice that these … | |
Re: >You normally don't need the ignore( ) between two input >statements of the same type. Or when the getline() is before the cin>>. | |
Re: Your program has too many errors to enumerate. You need to learn the basics (like you can't say Public instead of public; capitalization counts). Get a decent book and work through the examples. | |
Re: [icode]conio.h[/icode] (if available to you) has the function [icode]_getch()[/icode] which is unbuffered and does not echo the character read. | |
Re: Presumably something needs to be declared as virtual in Utility. Without code, it's hard to say exactly what. | |
Re: Let's see. There are 24 places that the pieces could be. There are 15 identical pieces for each player, and only one player's pieces can be in a particular position. The simplest data structure that fits these requirements is an array of 24 integers. Zero means the space is empty. … | |
Re: asin() in <cmath> Try [url=http://www.cplusplus.com/reference/clibrary/cmath/asin/]here[/url] for a description. | |
Re: And you're using double-quotes for character constants. You should be using single-quotes. |
The End.