5,676 Posted Topics

Member Avatar for restrictment

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, …

Member Avatar for restrictment
0
213
Member Avatar for smeghead007

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 …

Member Avatar for smeghead007
0
139
Member Avatar for philipghu

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

Member Avatar for jephthah
0
346
Member Avatar for pinknblu

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]?

Member Avatar for pinknblu
0
340
Member Avatar for Jeff_5_7

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) …

Member Avatar for Jeff_5_7
0
104
Member Avatar for blackmagic01021
Member Avatar for WaltP
0
104
Member Avatar for tquiva

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.

Member Avatar for Aia
0
154
Member Avatar for samarudge

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 …

Member Avatar for Geekitygeek
0
171
Member Avatar for abu taher
Member Avatar for Xufyan

[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 …

Member Avatar for Xufyan
0
211
Member Avatar for pranay_agg

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 …

Member Avatar for kunal kislay
0
135
Member Avatar for hondros

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.

Member Avatar for venkat arun
0
407
Member Avatar for gabz16
Member Avatar for tquiva

Other than [B]c[/B] being use to accept input [I]and[/I] count the number of 'c's, I seen nothing wrong.

Member Avatar for WaltP
0
122
Member Avatar for restrictment

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:

Member Avatar for restrictment
0
173
Member Avatar for MyrtleTurtle

: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:

Member Avatar for MyrtleTurtle
0
136
Member Avatar for sandyjain

I doubt it was [I]merely a coincidence[/I]. It was in fact well planned, with whatever differences designed for input vs. output.

Member Avatar for Banfa
0
161
Member Avatar for restrictment

[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 …

Member Avatar for trcartmill
0
233
Member Avatar for Sorb3t3ro

[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 …

Member Avatar for Sorb3t3ro
0
2K
Member Avatar for *Moonlight*

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 …

Member Avatar for jephthah
0
662
Member Avatar for dragonlvr4evr

[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 …

Member Avatar for WaltP
0
114
Member Avatar for skorm909

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.

Member Avatar for Luckychap
0
78
Member Avatar for ice616

[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] …

Member Avatar for Stefano Mtangoo
0
137
Member Avatar for rceena

[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.

Member Avatar for WaltP
-1
1K
Member Avatar for tcsarindam

[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) …

Member Avatar for Salem
-1
88
Member Avatar for drhelp

What does "[I]int[/I]" mean? What does "[I]double[/I]" mean? What does "[I]cannot convert[/I]" mean?

Member Avatar for WaltP
0
251
Member Avatar for awert

Yes we can. Start by reading the Member Rules and the useful posts at the top of the forum.

Member Avatar for WaltP
-3
79
Member Avatar for churni

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.

Member Avatar for churni
0
101
Member Avatar for riotburn

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.

Member Avatar for riotburn
0
119
Member Avatar for Mz3g

is this [CODE] if (buf == "TIME") { printf("Time: '%s'\n",msg); } [/CODE] the proper way to compare strings in C?

Member Avatar for abhimanipal
0
216
Member Avatar for loverdoll

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 …

Member Avatar for loverdoll
0
102
Member Avatar for ChrisXxX
Member Avatar for revenge2

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.

Member Avatar for akirue09
0
528
Member Avatar for zendet

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 …

Member Avatar for WaltP
0
456
Member Avatar for zrd0808

You do know you can say s[0], s[1], s[n] to get the characters of a string, don't you?

Member Avatar for zrd0808
0
2K
Member Avatar for hurricane123

[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 …

Member Avatar for WaltP
-1
593
Member Avatar for Asthuran

[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 …

Member Avatar for WaltP
0
1K
Member Avatar for fugnut

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 …

Member Avatar for MyrtleTurtle
0
150
Member Avatar for Freespider

How about [CODE]char dummy; char firstWord[10]; sscanf(text,"%c%s",&dummy, firstWord); [/CODE]

Member Avatar for WaltP
0
132
Member Avatar for wckddudeman

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.

Member Avatar for WaltP
0
208
Member Avatar for missmedude

So what's missing in [I]your[/I] triangle? What is necessary to get the *s in the right spot?

Member Avatar for WaltP
0
112
Member Avatar for Xufyan

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.

Member Avatar for Xufyan
0
126
Member Avatar for fsn812

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.

Member Avatar for mama_rock
0
529
Member Avatar for Iam3R

[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 …

Member Avatar for nezachem
0
226
Member Avatar for anjoz

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].

Member Avatar for anjoz
0
120
Member Avatar for jephthah

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 …

Member Avatar for Dave Sinkula
0
157
Member Avatar for TimCereja

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.

Member Avatar for TimCereja
0
362
Member Avatar for NeedHelpWithC++

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 …

Member Avatar for creative_m
0
200
Member Avatar for bdrkb
Member Avatar for pearle

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?

Member Avatar for WaltP
0
158

The End.