5,676 Posted Topics
Re: Why are you putting a [ICODE]for[/ICODE] loop inside the [ICODE]while[/ICODE] loop? The [ICODE]for[/ICODE] loop will get in your way if there are less than 8 values. | |
Re: Your program is backwards. You want to 1) start a loop 2) ask for input 3) use the switch 4) continue with loop until exit command entered | |
Re: [QUOTE=jprogram;1183939]I have been trying to do this assignment for the past 4 days. I thought I was doing good but the functions seem to be screwing up. All the greater than and less than functions are messing up. Also the add and subtract functions are messed up. Any suggestions would … | |
Re: This code will not do what you want: [CODE] //Populates the grid with x's for(int i=0;i<5;i++) { lifeBoard[rand()%19][rand()%19] = 'x'; } //Populates the grid with o's for(int i=0;i<100;i++) { lifeBoard[rand()%19][rand()%19] = 'o'; } [/CODE] What if during the population of the [B]o[/B]'s you overwrite an [B]x[/B]? | |
Re: [QUOTE=3cats;1177824]I have never posted to a forum before. I am taking a beginning C++ prgmming class. [/quote] It shows. You didn't bother to read the Member Rules and made a bad post... Start by [url=http://www.gidnetwork.com/b-38.html]formatting your code[/url] so you can follow it. This error is almost always because of misplaced … | |
Re: Stop writing code that causes C2664 and C2562 errors would be a usable suggestion. That might mean looking up what the errors mean and either memorizing the descriptions & sulutions or writing them down for future reference. | |
Re: All you are doing is testing the first character and returning 1, 2, or 3. You need to set a variable to 0. Instead of returning in your loop, set the variable to the appropriate number. But be sure to check the value before setting it otherwise the value will … | |
Re: Internet Code Lesson #1: a) If you want to llearn how to do a task by looking at code b) If the code you found doesn't work z) Do not use it. Find something else. Why bother with it if [B]IIIX[/B] == 13. What can you learn? | |
Re: Because 1% of the posts that resurrect an old thread might actually have some useful information -- not for the OP but for someone just dropping in. 80% cause problems by 1) Hijacking the post 2) Posting bad code requiring people to correct it 3) Posting wrong code requiring people … | |
Re: And [I]please[/I] fix your indentation! It's very hard to read. | |
Re: Jeez! [ICODE]if (false)[/ICODE] is always false because [B]false[/B] is -- wait for it -- [I]false[/I]! | |
Re: 1) [url=http://www.gidnetwork.com/b-58.html]See this[/url] about using [iCODE]feof()[/iCODE] 2) Write a truth table for your 2 [iCODE]while()[/iCODE] statements and see what they should look like. | |
Re: [QUOTE=mommie;1183645]Thank you that actually worked. I tried single quotes but not double quotes. I don't know why I didn't try double quotes in the beginning. [/quote] Programming isn't a trial and error process (at least not with syntax). If you have a string, you [I]know[/I] if and when, and which … | |
Re: [QUOTE=DawnDenise;1182612]I would like the output of this string to display each word in a column and ignore all punctuation. I have tried including an if statement that tells the string to start on a new line when a space is encountered but I haven't had any luck. Any hints are … | |
Re: [QUOTE=Robert1995;1181766] [CODE] //And a shuffle system void switch_with_last(long cards[53],int pos){ long aux; aux=cards[cards[0]]; cards[cards[0]]=cards[pos]; cards[pos]=aux; } int shuffle(long cards[53]){ int i,shuffles; srand(time(NULL)); for(shuffles=1;shuffles<=500;shuffles++){ i=1+rand()%cards[0]; switch_with_last(cards,i); } } [/CODE] [/QUOTE] This has 2 problems. 1) [ICODE]srand()[/ICODE] should only be called once -- at the beginning of the program. 2) This is … | |
Re: I really get tired of people simply saying "it doesn't work" and expecting us to figure out what it's doing wong. [B]Tell us[/B] what doesn't work. What happens? Does is crash? Does it melt the monitor? Does it bomb South America? If you need help -- give [B]DETAILS[/B] | |
Re: [QUOTE=skorm909;1182709]oh well im sorry it just looks better this way to me i even showed you where the errors are so i dont see why thats a problem[/QUOTE] If that code looks better to you than properly indented code, then you may as well expect to have lots of problems … | |
Re: Do you know how to use the computer you are trying to copy the files from? [QUOTE=jwenting;1181652]MS-DOS is NOT available in Windows XP, nor is it in Windows 98. It was retired with Windows 95. There is a command shell that has pretty similar commands available to it, but that's … | |
Re: [CODE] int LoadArrays (ifstream& inputdata, int age[], double premium[]) { int index = 0; while ( index < Max_Array && inputdata >> age[index] >> premium[index]) { index ++; } [/CODE] In my opinion, this loop is more confusing than it needs to be. If you want to use [I]Max_Array[/I] like … | |
Re: [QUOTE=jgehlot09;1179503]I have a file name fun.c contain the fuction to add two number (addnum(a,b)).Now I create another file name callfunc.c.Here I want to call the function (addnum(a,b)) from the file fun.c. How can I do that?.[/QUOTE] Create a header file [I]fun.h[/I] with a prototype of the function. Add [ICODE]#include "fun.h"[/ICODE] … | |
Re: Just set up a buffer of [B]x[/B] chars. Open the file for binary read. Loop, reading [B]x[/B] chars from the file. Write the characters. Exit the loop when the read does not actually get [B]x[/B] chars -- you've hit EOF. | |
Re: And if you want us to be able to read your code [url=http://www.gidnetwork.com/b-38.html]format it[/url]! | |
Re: You are making things very hard for yourself. Just use the [ICODE]scanf()[/ICODE] and check the return value. You don't need the [ICODE]ungetc()[/ICODE]. Other changes: Get rid of the [B]\t[/B]'s in the [ICODE]scanf()[/ICODE] format. They aren't needed. Exit the loop when the return from [ICODE]scanf()[/ICODE] is not as expected And [url=http://www.gidnetwork.com/b-38.html]format … | |
Re: [CODE]Public Class Form1 Private Sub btnCompute_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCompute.Click Dim pizza, fries, drinks As Double ' inputs by customer pizza = CDbl(txtPizza.Text) fries = CDbl(txtFries.Text) drinks = CDbl(txtDrinks.Text) displayBill(pizza, fries, drinks)[/code] You are calling the function with the number of items ordered (I think- … | |
Re: [CODE]Read a line Loop [I]strchr()[/I] for a SPACE or EOL copy characters before the space to another string Use [I]strcmp()[/I] and loop to find the letter Test the next character for SPACE. If so, output another space Skip to next morse character Endloop [/CODE] | |
Re: Not even going to bother. First, [url=http://www.gidnetwork.com/b-38.html]format your code[/url] so we can read it. Next, ask a question we can answer. That starts with details of the problem, not just posting the assignment and nothing else useful. | |
Re: Dis iz error: U dint explan nutin. U writ 2 mch cde an dnt tst it. Plzzzz expln wat prblm iz. We dun unrstnd prblm. && U dint spk English. Cnt unrstnd not English | |
Re: [QUOTE=lotrsimp12345;1154838]don't do it with a stack you are typing too much... use recursion very powerful and easy to understand.[/QUOTE] Just because you learned recursion recently and it looks kool, it is rarely an acceptable alternative to a loop. Way too many resources are used and you can crash your computer. | |
Re: What does "comes out wrong" mean? Maybe details would help. | |
Re: Yeah, so? Do you have a question we can answer? | |
Re: It's identical to what you've found. The data just comes from somewhere other than the keyboard. So the data input is a little different, all the rest is the same. | |
Re: also, [iCODE]facesInhand[numberInHand2][13][/iCODE] is beyond the array. The array stops at 12, not 13. | |
Re: [QUOTE=abu taher;1164935]if you convert 10 to 'ten' then try this No declarations at all. 1. Create a form and add two textboxes; TextBox1 and TextBox2 2. Add a command button; CommandButton1 3. Copy the code below to the code window. 4. Run the program, enter the number in TextBox1 and … | |
Re: Write them to a settings file of your own creation. | |
Re: Only if each and every line is exactly the the same length. If they aren't, you have no way of knowing where any line starts. | |
Re: Get a degree. In the 60's and 70's it was easier to get a job without one. But today, why would you hire some self-taught person rather than someone that has a formal education? Would you buy a house built by the guy's brother-in-law executive that likes woodworking or one … | |
Re: First warning: [I]disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.[/I] You don't care that VC doesn't like strcpy so turn the error off. Next error: look on line 21 and before for the missing ';' | |
Re: You have to move it then. What you are doing is [CODE]output a character at the left edge of screen; wait; output a tab; return to left edge; repeat;[/CODE] How can you put the character where you want it? | |
Re: I'll bet its your [iCODE]while (!file.eof())[/iCODE] statement. [url=http://www.gidnetwork.com/b-38.html]See this[/url] ([ICODE].eof()[/ICODE] is the same as [ICODE]feof()[/ICODE] | |
Re: [B]user_book[count].bn[temp][4][/B] is a single character. Change it to [B]user_book[count].bn[temp][/B] | |
Re: [QUOTE=n.utiu;1179054]Use C++ string, they are better, and more stable.[/QUOTE] C-strings have been around a lot longer than the C++ string class -- therefore they are quite stable... | |
Re: [QUOTE=Asheem;1179565]Guys, in this program, we have a file by the name of asharray.txt, which is attached to this post, and we have three functions: 1.to read the file 2.to sort the numbers 3.to write to a separate file by the name of( array result.txt) Sp, here I faced some problems, … | |
Re: I'd search Google rather than searching forums. There's more detailed information there. | |
Re: So what is it doing instead? | |
Re: Add the program to the Start=>Programs=>Startup list. It will start when the user logs in. | |
Re: And [url=http://www.gidnetwork.com/b-38.html]format your code[/url]. It's very difficult to follow. | |
Re: You actually did it in reverse. [code] int main() { char *namen; char test[255] = "Test"; namen = test; cout << test << endl; cout << namen << endl; return 0; } [/code] The pointer can receive the address of the array. Not the other way around. | |
Re: [QUOTE=Fenlevi;1178820]It still does not work,maybe my function definition for two dimensional vector is not right?[/QUOTE] Maybe you sould post the [I]exact[/I] error message and tell us the [I]exact line[/I] the error points to. That way we don't have to guess. | |
Re: Use 2 indexes, 1 for '[I]student[/I]', 1 for '[I]new position[/I]'. Start them both at 0. Increment both indices until you find the student you want to remove. Increment only the student index. Now continue to the end of the array copying the values in the '[I]student[/I]' index into the positions … | |
Re: And it's not dependent on the [I]operating system[/I]. It depends on the [I]compiler[/I]. |
The End.