5,676 Posted Topics
Re: If [icode]menu()[/icode] returns a value, then return the value. It should be a [ICODE]char[/ICODE], not [ICODE]void[/ICODE], function. | |
Re: Try reading some of the sticky posts that are labels [B]Read Me:[/B] to learn good posting techniques... | |
Re: [QUOTE=Alibeg;818401]@csurfer i thought that you cannot read a string like [icode]scanf ("%s", stu_name[j]);[/icode] if you defined [icode]stu_name[/icode] like [icode]char stu_name[MAX_LENGTH];[/icode][/QUOTE] Yes you can, but you shouldn't. If your string has a SPACE in it, you only read up to that space. And reading a string with [ICODE]scanf()[/ICODE] is identical to … | |
Re: [QUOTE=siddhant3s;818559] BTW,[icode] char chr_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\0'};[/icode] is same as [icode] char chr_digits[] ="0123456789";[/icode][/QUOTE] True. But based on the code you don't seem to need a [I]string[/I], just an array of characters. So [icode]char chr_digits[] = {'0', '1', '2', '3', '4', … | |
Re: [QUOTE=cscgal;98982]Hey there, 1o0oBhP ....... err, that was quite a mouthful (err, keyboardful) spelling out your name :) [/quote] That's why I cut'n'paste :icon_smile: [QUOTE=cscgal;98982]In any case, we like to make it a general policy not to create new forums until we see a need. The phrase "build it and they … | |
Re: I'm not sure how adding if statements for edge checking makes the code simpler. In my experience, additional code always complicates, rarely simplifies, readability. | |
Re: [QUOTE=Fouly;811863]Hi, I'm trying to pass parameters to an exe file using C++...i tried the following code: [code] system("FileName.exe"); [/code] but this command line just fire the .exe file without passing any arguments... Thanks, Mostafa Fouly[/QUOTE] In order to pass arguments you have to pass arguments. All you did was execute … | |
Re: IMAO, giving bad rep then giving good rep to nullify it is asinine. If you think they deserve bad rep, give it. If you're concerned about their rep points going in the toilet, don't give it. The only thing I've seen in this thread that makes even a little sense … | |
Re: [QUOTE=yang120;811918]why and?? because is like the user only need to put a or b not a and b[/QUOTE] Because with OR the comparison is [I]always[/I] true. The only way the IF can be false is if [icode]input[position][/icode] is equal to [I]all[/I] of the letters, an impossibility. The other reason is … | |
Re: First, please learn to [url=http://www.gidnetwork.com/b-38.html]Format your code[/url] so we can read it easier. You need to store each factor in an array as you generate them. Using your 100, you first generate 2. Save it in the array and you have 50 left. Run the loop again on the 50 … | |
Re: The idea behind c-strings is that they end with a '\0' character. You have defined the array to be 11 characters then ask for 11 characters. There is no room for the \0. You must only read 10 characters. And on a style note, if you ask for the string … | |
Re: You're reading into an integer and each line contains an integer. Even though you didn't explain what you actually want I assume you mean to read each individual [I]digit[/I] into the [B]j_mapKey[/B] array. If so, read each digit as a [I]char[/I] and convert to an integer by subtracting 48. | |
Re: Now read the information 1) in [url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_policies]the Rules[/url] you were asked to read when you registered 2) in the text at the top of this forum 3) in the announcement at the top of this forum titled [url=http://www.daniweb.com/techtalkforums/announcement8-3.html]Please use BB Code and Inlinecode tags[/url] 4) in the sticky post above … | |
Re: You really need to tell us the [I]real[/I] problem, which is "I cannot get the program to compile. The error message I get is..." You cannot define a function within another function as you are doing. [B]round()[/B] cannot be within [B]main()[/B]. | |
Re: Making a change to [B]RF[/B]'s equation will give you the ability to get random numbers in [I]any[/I] range. Add a [icode]start[/icode] and a [icode]range[/icode] variable: [icode]((int) (range * (rand() / (1.0 + RAND_MAX))) + start) [/icode] So, if you want numbers from (and including) 3 through 10, [icode]start[/icode] is 3, … | |
Re: There is no built in way. Easier? Can't think of anything easier than checking characters. | |
Re: Since you never initialized [ICODE]command_array[/ICODE], it starts out with junk in it. Then you added your input to that junk. Is the first parameter to [ICODE]execvp[/ICODE] supposed to be a single character? That's what you are passing. After making changes you should repost the code so we can see it's … | |
Re: The problem with [B]AD[/B]'s solution is you never really know when you're at the beginning of a line. You can: Read a complete line. Test the beginning for the word in question. If found, there are many ways to 'parse' the line. 1) looking at each character and dealing with … | |
Re: [QUOTE=RexxX;800926]Well, I want to know how to insert a full string into the array of strings. I thought it might be: [code]fscanf(infile, "%s", *arr[i]);[/code] but this line gave me the error "warning: format argument is not a pointer (arg 3)".[/QUOTE] No. It would be [icode]fscanf(infile, "%s", arr[i]);[/icode] But, [url=http://www.gidnetwork.com/b-62.html]see this … | |
Re: Start by writing a program to determine the prime numbers less than 1,000,000. Then modify the program to test the differences. | |
![]() | Re: [QUOTE=flip.phinoi;800473]Sorry about that... noobie :)[/quote] Not an excuse. There are at least 6 places where CODE tags are suggested/described. The first is in the rules you were asked to read when you signed up. The last is right on the background of the input box you typed your message into. … |
Re: I hope you get a good grade on the assignment, [B]Comatose[/B] | |
Re: Actually, you can't assign a char to a string, but you can [I]add[/I] a char to a string. A minor change to you program above: [code=cpp] int main() { string user_input; string first = ""; getline(cin,user_input); first += user_input[0]; cout << "Frist character is " << first << endl; return … | |
Re: [QUOTE=niek_e;796511]There are a few thing wrong with your code : - you're incrementing 'i' twice in your word_count function. That's not good. You're missing characters because of this and you'll probably run out of array-bounds.[/quote] Not really. There loop [B]only[/B] increments [ICODE]i[/ICODE]. That's the only real problem. [QUOTE=niek_e;796511]- Why use … | |
Re: Not a clue what you are talking about. | |
Re: To expand on what [B]vmanes[/B] said, create a 2D array, something like [ICODE]inputbuffer[4][250][/ICODE] (4 lines, 250 chars each). Reading each character, load the characters in the array. When you reach the end of one line from the file, add a \0 character and point to the beginning of the next … | |
Re: [QUOTE=peter_budo;793334]Yes, it is cool side, but I see no reason to spam around the forum without reason...[/QUOTE] One post IMO is not "spam[ming] around the forum" | |
Re: getline will read the entire line, then you'll have to break up the line read into its individual strings. Alternatively, you can use >> to read in each individual string. >> will stop reading at whitespace. | |
Re: Can't be done. Change your message to [B]Press ENTER to continue[/B] and just use the standard I/O functions. | |
Re: My guess would be that this loop [code=c] for(loopcounter=9; loopcounter!=NewRank; loopcounter--) { [/code] exits when [I]loopcounter[/I] equals [I]NewRank[/I] so [code=c] if(loopcounter==NewRank) { ListToBeChecked[loopcounter].TimeTaken = Time; strcpy(ListToBeChecked[loopcounter].Username,UsersName); } [/code] is never executed. Also, [url=http://www.gidnetwork.com/b-57.html]see this[/url] about [ICODE]fflush(stdin);[/ICODE] [url=http://www.gidnetwork.com/b-56.html]and this[/url] about [ICODE]gets(UsersName);[/ICODE] | |
Re: * You also didn't bother to read the rules as requested multiple times during registration (code tags and the title show that) * you didn't format you code so people can read it * you somehow think people are here just to bail you out of your problem and don't … | |
Re: The problems I see in that function: 1) using [ICODE]getch()[/ICODE] -- [url=http://www.gidnetwork.com/b-43.html]see this[/url]. 2) recursively calling fnAddDepartment(); because an invalid department entered. Should simply loop back to reenter the value. 3) Your formatting does not make it easy to read the function. [url=http://www.gidnetwork.com/b-38.html]See this about formatting[/url]. | |
Re: Who says the 'buffer on the stack' is formatted properly for [icode]sscanf()[/icode]? | |
Re: You were asked to use code tags which are described 1) in [url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_policies]the Rules[/url] you were asked to read when you registered 2) in the text at the top of this forum 3) in the announcement at the top of this forum titled [url=http://www.daniweb.com/techtalkforums/announcement8-3.html]Please use BB Code and Inlinecode tags[/url] … | |
Re: The only correction I can see, and it's minor, is that [I]postconditions[/I] is not a valid English word. | |
Re: You said the temperature in the file is in the format C23.4 F74.7 Where did you read the C or F? Where did you test the C of F to decide if you need to convert? | |
Re: [QUOTE=csurfer;787859][QUOTE=Aia;787248][ICODE]scanf("%[^\n]",str);[/ICODE] Do you want to bet I can overflow the 15 characters that str[] can hold?[/QUOTE] Wat u said regarding the overflow of string array is perfectly right...but my question is can such overflow of array's at such subtle level cause major damages.? if yes how.? and what to refer … | |
Re: Your shuffle seems backwards to me. Assuming [I]card[/I] values mean something like 1 = 2 of clubs 2 = 3 of clubs ... 13 = A of clubs 14 = 2 of Diamonds ... 52 = A of Spades I'd change the shuffle to something like this... Fill an array … | |
Re: That's how sscanf works. A decimal is illegal for integers so the translation ends. You'll have to reconsider how you read/translate the file. Also, consider these problems: [url=http://www.gidnetwork.com/b-66.html]see this[/url] about [icode]void main()[/icode] You've defined [icode]c[][/icode] to be 10 characters. How many characters are in the first line for [i]textfile.txt[/i]? And … | |
Re: Usually you change the buffer in memory, then write the whole buffer to the file after all the changes are made. Don't try changing the file as you change the display. | |
Re: Now I'm completely confused. In your first post you state [quote]am trying to append to file but its not going correctly[/quote] The problem is you open the file for append (write at end) then try [I]reading[/I] from the file. That's just backwards. Then: [QUOTE=Jacky1;786265]but what if I want read from … | |
Re: [QUOTE=thekashyap;318192]3. Optimizing the breaking conditions in for loops. If you know that the loop variable's range is from 0 to some +ve number AND it doesn't matter which way you traverse while looping, you can optimize the loop like this: [code=c++] //original loop for( int i = 0; i <= … | |
Re: So far, I like the look although I haven't explored fully. The first thing I noticed that I'd like corrected is putting the "Community" tab back on each page rather than accessed only at the bottom of the main forum page. | |
![]() | Re: Come come people. Look at the code. You can't read an [B]integer[/B] using [B]%c[/B] |
Re: Reread Ancient Dragon's post. He did say change the #include statement, but that wasn't all he said... | |
Re: You need to search out the binary AVI file format and read the file header. The length should be in the header. | |
Re: [QUOTE=bamabambhole01;770131]try ./filename[/QUOTE] What does this do? | |
Re: YEs, there are quitre a few people here that can help. What have you got so far? | |
Re: Don't you know the universal icons for... for... heck, I don't know either!!! |
The End.