5,676 Posted Topics
Re: Easy way: Copy the string a character at a time into another string in a loop. Don't copy the punctuation. Harder way: Set up two indices, one ([I]indOrig[/I]) for pointing at the original string, one ([I]indNew[/I]) for pointing at the new character position. Both start at 0. During your loop, … | |
Re: So you read the entire file into the single string [ICODE]num[/ICODE] [CODE]while (!inFile.eof()) { getline (inFile,num); cout << num; } [/CODE] Then you call [ICODE]bubblesort()[/ICODE] passing in the one string value [ICODE]num[/ICODE] and sort this one value [ICODE]maxSize[/ICODE] times. [CODE] bubblesort(num,maxSize); outFile.close(); inFile.close(); [/CODE] What happens when you try to … | |
![]() | Re: Even though what you want to do makes no sense, 1- Use [ICODE]lseek()[/ICODE] to get to the end of the file. 2- [ICODE]lseek()[/ICODE] back one character 3- read the character 4- repeat 2&3 until you get to the beginning of the file |
Re: Assume score input is 30,40,50,60,70. In your FOR loop, when [I]quiz[/I] == 0, what value is element [I]grade[quiz-1][/I]? | |
Re: You need to input multiple digit numbers, right? So you need arrays for your data. What's the largest number you want to handle? Create arrays at least that large. The way I did it is have 1 input array (char) and 3 calculation arrays (2 number and 1 answer) 1) … | |
Re: [B][url=http://www.gidnetwork.com/b-45.html]This might help[/url][/B] | |
Re: Did you actually [I]try[/I] to read the first 4 numbers on one line? That wold be your first job. Just try something. If it doesn't work, we can help. If it does, you don't need us, nor the big wait time (1.5 hours for this one) waiting for an answer. | |
Re: No, it's a real shot (actually two) of that street. As google (or whoever) goes around taking pictures for the street views, the cars and pedestrians move between shots. Sometimes not enough so you get that effect. If you look at the LA link (if not active check around the … | |
Re: [url=http://lmgtfy.com/?q=make+help+file]Try This[/url] | |
Re: [QUOTE=Xufyan;1167447]alphabet from lower to upper , using ascii what logic should be use to convert small letters into capital using ascii codes?? for example ascci code for A is 65 and ascii code for a is 97 how can i coonvert from integers to character ?[/QUOTE] Such confusing responses.... What … | |
Re: Look at each characters in [B]ss[/B]. Use a loop so [B]i[/B] increases for 0 to #characters ins [B]ss[/B] If [B]ss[i][/B] is not an integer, go to the next character If [B]ss[i][/B] [I]is[/I] an integer, subtract '0' from the character (this changes '2' into 2) and store it as required. Another … | |
Re: Do you know how to use the % operator? You can take your integers and split them into 3 digits which can be converted into characters. | |
Re: Other than [B]c[/B] being use to accept input [I]and[/I] count the number of 'c's, I seen nothing wrong. | |
Re: Wow, everyone replied at the same time. Happens quite often. Makes my head swim.Yep, they sure did. What the hell, I'll post mine anyway. I won't. Now your best bet is eenie, meenie, miney, moe. :icon_mrgreen: | |
Re: :D When you post answers to questions here do people jump down your throat about using bad techniques, commands, formatting? :twisted: that would be clue #1...:icon_mrgreen: | |
Re: I doubt it was [I]merely a coincidence[/I]. It was in fact well planned, with whatever differences designed for input vs. output. | |
Re: [QUOTE=restrictment;1167532]Yes, I am fairly familiar with the getline function, but not so much with getting a line from a text file.[/QUOTE] Do you have a problem with tutorials, text books, and Google? That is where you do the first level of learning. We are here to fine tune what you … | |
Re: [QUOTE=Sorb3t3ro;1163791] I dont like using [B]system("PAUSE")[/B] and I changed it to cin.get() but I noticed that cin.get() isn't working on some of my programs then I use system("PAUSE") then it worked. But for this program cin.get() is working. Thanks for your effort.[/QUOTE] That's because the other programs probably left the … | |
Re: Please stop [B]bolding[/B] your messages. If you look through these forum, you will not see messages in bold. You start the loop just above the first line you need in the loop. That varies with every program. Usually above the initialization of values that must be set every time thru … | |
Re: [QUOTE=hay_man;246195]I am using c++ and need to devise a method to determine the check digit of a credit card. The user enters the card no. as a string. The card no is then divided into blocks of length, x. these blocks are then added. I have the code to convert … | |
Re: I have no idea what you want. The answer as I understand the question is "[I]don't call the function until you want it.[/I]" But since that's obvious, that can't be what you're asking. | |
Re: [QUOTE=evstevemd;1167231]if you make two for loops nested like above, for each value of x, it will iterate to all values of y and go to next iteration which will do the same until all values of x are finished[/QUOTE] In other words, it will loop over all values of [B]y[/B] … | |
Re: [QUOTE=rceena;1166809]I want to convert binary file to ascii. how to do that in C[/QUOTE] Depends completely on what you need. Be less vague. And if you want to now in C, why not post in the C forum, not C++ forum. | |
Re: [QUOTE=tcsarindam;1166949]Using different objects for input and output the above code is not working. Pls give suggestion ASAP. [/QUOTE] The suggestion depends on what the code is supposed to do. Since you didn't tell us, what can we we suggest? at least other than Never use [ICODE]gets()[/ICODE], for various reasons 1) … | |
Re: What does "[I]int[/I]" mean? What does "[I]double[/I]" mean? What does "[I]cannot convert[/I]" mean? | |
Re: Yes we can. Start by reading the Member Rules and the useful posts at the top of the forum. | |
Re: Going back to your original function, between runs you have to have a way to zero your counter. Using a static value, you can't zero [B]i[/B] when the new run starts. | |
Re: Since I have no idea what a "[I]bootstrapping bond interest rates[/I]" is nor how to calculate it, I would suggest letting the program tell you what's wrong. Before and after key calculations, display values and check them to make sure they are as you expect. | |
Re: is this [CODE] if (buf == "TIME") { printf("Time: '%s'\n",msg); } [/CODE] the proper way to compare strings in C? | |
Re: Go to the principal or dean and explain to him that your instructor is handing out assignments without teaching the material, and he's forcing you to use a compiler that is 20 years old. You cannot learn adequately from a 20 year old compiler nor an instructor that won't teach … | |
Re: To get a binary value from a decimal value [icode]v = val %2;[/icode] -- [B]v[/B] will contain the value of the [I]one[/I]s digit. Then, after you get the digit, remove it to get the next digit: [icode]v = val /2;[/icode] Loop until [B]val[/B] is 0. | |
Re: Start at the top. 1) Create something in the program that holds 10-20 words. Add a loop to print the words. Compile and correct until it has no errors and displays what you've done correctly. 2) Add some code to choose a random word. Output the word. Compile and correct … | |
Re: You do know you can say s[0], s[1], s[n] to get the characters of a string, don't you? | |
Re: [QUOTE=CaneIsACheater;1166417]Hurricane123 is a cheater. I recognize this code, it's our department chair's code and he/she knows it. Hurricane123 is trying to cheat their way out of doing the assignment the RIGHT way, by getting the daniweb community to write it. [/QUOTE] Thanks for the heads up. But if you read … | |
Re: [QUOTE=MyrtleTurtle;1165481]I [I]might [/I]be using anything...but I [I]am [/I]using Dev-C++ for now. I also have VS C++ 2008 Express, but haven't used it much yet.[/QUOTE] In addition (if it hasn't been pointed out yet) Mixing [ICODE]cin[/ICODE] with [ICODE]getchar()[/ICODE] should not be done. Stick to one style. [QUOTE=CreativeCoding;1165582]Meh... Whenever I don't feel … | |
Re: Every time you input [I]shape[/I], display it as a character and and integer. You will see immediately what's wrong. Things to look at: 1) Let the program tell you what is wrong. Output values to be sure they are correct. 2) [url=http://www.gidnetwork.com/b-38.html]Format your code[/url] better. There is no reason to … | |
Re: How about [CODE]char dummy; char firstWord[10]; sscanf(text,"%c%s",&dummy, firstWord); [/CODE] | |
Re: There is not enough information to even make a bad guess. There is absolutely no context given. Your best bet is to use your debugger and find out what line your error is on, then look at all the related values. | |
Re: So what's missing in [I]your[/I] triangle? What is necessary to get the *s in the right spot? | |
Re: So what's wrong? The program description doesn't make sense, but the code has only 1 minor error -- the [iCODE]for[/iCODE] statement is a little off. | |
Re: Learn both. They both have their uses and one can do things better than the other in many cases. It also gives you the ability to choose the best language for the job. | |
Re: [QUOTE=nezachem;1164692]The [I]compiler [/I]can't possibly do that. The conversion happens at runtime, by crt0 or something else.[/QUOTE] Sure it can. On the proper system, when the program returns 0 to 'the system', the compiler adds exit code to the program to convert that 0 to the proper value before returning control … | |
Re: Not even going to try reading that badly formatted code. Do instructors [I]really[/I] teach that indenting 30 characters is a good thing? Try [url=http://www.gidnetwork.com/b-38.html]this information[/url] I just happen to notice [url=http://www.gidnetwork.com/b-57.html]this, too[/url]. | |
Re: What [B]jephthah[/B] says is correct, but by [B]not[/B] passing "cowandchicken" into [iCODE]atoi()[/iCODE] you won't have a problem. You need to look at the characters anyway. This is the verification phase of any conversion. Make sure you pass digits at the front of the string and you're fine. Anyone that would … | |
Re: Look at the characters. If there is a digit, subtract '0' to make it a number and accumulate it into a variable -- details for you to work out. If you get a /, next digits go into another variable. | |
Re: Good start, although don't indent so far. 4 spaces is more than enough. 32 makes your code unreadable. [url=http://www.gidnetwork.com/b-38.html]See this[/url]. [CODE] for (int i=0; i<3; i++) { for (int j=0; j<27; j++) {[/CODE] If your matrix is defined as 28x4, why are you reading 3x27? Use the dimensions you gave … | |
Re: Why are you using a [iCODE]while[/iCODE] statement in a recursive function? It is going to cause a major problem on the return rewind. Turn it into an [iCODE]if[/iCODE]. Also, if [B]x[/B] is negative, is [B]x/-10[/B] negative or positive? |
The End.