1,608 Posted Topics

Member Avatar for Dabdob

C is a language, not a piece of software. If you want to download some software to compile a program written in the C language, you can go to Bloodshed's web site and download DevC++ IDE---for free, and it's got a good rep! You can compile either C or C++ …

Member Avatar for perniciosus
0
192
Member Avatar for some one

To me a standing order means add/delete a certain amount on a certain day of each month. Obviously there are other definitions, too, so you really need to decide exactly what you want to do. It could be as simple as extracting the day of the month field from the …

Member Avatar for some one
0
257
Member Avatar for new guy n c++

What is(are) your specific question(s)? The use of functions is a large topic. For example: Functions do something to something and return something. The name of the function is the key to keeping track of it all. You need to declare the function before you use it. This is often …

Member Avatar for Ancient Dragon
0
164
Member Avatar for Halcyon

Since the program can't know in advance whether a given name in Names will have 2 or three tokens, I would use an array of char * store each token as it was developed, and an index to keep track of how many tokens found in each string. After each …

Member Avatar for Halcyon
0
157
Member Avatar for fidelljf

That works if the user enters three names. If they only enter two names you will have the last name as the middle name, though. If you're not familiar with stringstreams as demonstrated by Dave Sinkula you can parse the entire line using other techniques such as strtok() or your …

Member Avatar for Lerner
0
140
Member Avatar for diddle

Are you: A) interested more in the math or B) how to use the math in your games or C) do you have a project in mind and think you want/need to use this type of stuff but aren't sure what to do? For A, I've gone back to my …

Member Avatar for diddle
0
168
Member Avatar for TimC

I find it useful to think of a list as a sequence of objects, frequently called links or nodes, linked by pointers. The link/nodes can be instances of a struct/class which in turn contain both a data object and at least one pointer. In C you can only use structs …

Member Avatar for SpS
0
165
Member Avatar for some one

And the question is? If I were to approach this project I'd use an outline somthing like this: [code] A) Bank I) Container of Accounts II) Add Account III) Delete Account IV) Display single Account V) Display all Accounts VI) Process Standing Orders in Accounts B) Accounts I) Type a) …

Member Avatar for some one
0
403
Member Avatar for kharri5

When coding I recommend your write and test only a couple lines, or at most a single function, at a time. Since CardPile seems to be the first thing you wrote I'd start there. Given the constructor you posted I suspect you want CardPile to have a member that is …

Member Avatar for perniciosus
0
248
Member Avatar for sahil_logic

Dont declare functions inside of other functions (in this case inside main(), and when you call a function and need to pass it arguments, don't indicate the argument type, just the argument name or an objects address (if the function is expecting a pointer and what you have is an …

Member Avatar for dwks
0
111
Member Avatar for guideseeq

Yes, I downloaded that a fortnight before! What can I do with that exe file. During college days, I used Turbo C :surprised >>exe is the extension name given to the executable file generated by your compiler/linker/IDE. Running that file on a computer with appropriate software support will allow the …

Member Avatar for perniciosus
0
454
Member Avatar for Zababa

>I hope there is another way There is! It's called the Standard Template Library. Using a vector of strings (both vector and string are STL classes) would do the trick very nicely. If you need to use native char arrays, then you could do this: const int MAXSTRINGLENGTH = 256; …

Member Avatar for jim mcnamara
0
415
Member Avatar for snaidis

Input equation as a string. Evaluate string one char at a time. isdigit() will return true if the char is a digit. Collect all consecutive digits (you will need to account for decimal point if your equation allows decimal numbers rather than just integers) in a holding string. Once all …

Member Avatar for SpS
0
177
Member Avatar for kahaj

comment out one function at a time until you get back to a spot where it does compile. The last item you commented out probably has the error. Once you've found the function that's giving you trouble comment it all out to an empty body and start adding back one …

Member Avatar for Dave Sinkula
0
240
Member Avatar for peter_budo

You can only return a single item using a return statement. In the function definition you indicate that find will return a string. In the return statement you appear to be trying to return two strings and an int. It may work, but I doubt it. The compiler appears to …

Member Avatar for SpS
0
182
Member Avatar for christyj5

I view programming as a four step process. First I have to have the inspirition to start a project (or it is something I'm forced to do). Second, I have to think my through the project, usually ruining several pages of paper filled with failed algorithms. Third I write the …

Member Avatar for jim mcnamara
0
253
Member Avatar for Dee_Dee

Many people would argue that limiting using directives to include only those items in a namespace that will be actually used instead of opening up all of the namespace would be prefered to something like the using namespace std statement. Even more limiting, and therefore more precise, if more onerous …

Member Avatar for SpS
0
267
Member Avatar for Hisham4FCI

I suspect the fstream has gone into a failed state after the first read because you read through the entire file and encountered EOF which triggered the fail bit. Try placing this line: File.clear(); after the while loop is done, (so you've stopped the loop because you got to the …

Member Avatar for Lerner
0
205
Member Avatar for new guy n c++

If you can try to write your program in skeletal form before even trying to write the code I think you will do better. Using the program description, here's how I might write out the general outline of what I wanted to do. [code] declare input file declare output file …

Member Avatar for Lerner
0
425
Member Avatar for dj_money

Using cin >> will pause the program until input occurs. My suggestion would be to consider using kbhit() from the non-standard conio.h file (not all compilers have this file). Sprinkle calls to kbhit() before or after any critical sections and if you want to quit only if a keystroke was …

Member Avatar for brian63304
0
2K
Member Avatar for some one

Here's a simplistic approach. [code] if(acc_bal) tax= acc_bal*.025; //subtract tax from account balance to get new account balance //transfer tax to the the tax account for the bank. create a Bank class to: hold: //a container to hold all Customers //a variable to hold running total of all taxes collected …

Member Avatar for some one
0
240
Member Avatar for kahaj

Work on just one animal at a time. Using pen and paper develop an equation that will calculate the position of that animal at any given point in time given the original starting position of the animal and the number of positions per unit time the animal advances. I'd probably …

Member Avatar for Dave Sinkula
0
232
Member Avatar for Cudmore

No compiler at moment to confirm, but I'd try this: ModStr(strMyString); instead of this: ModStr(&strMyString); as the name of the string is the address of the first char of the char array making up the string, unlike the names of other types of variables. This won't work because you can't …

Member Avatar for Cudmore
0
138
Member Avatar for btech

You need to deal with the back pointer in each of the new nodes you are creating.

Member Avatar for Lerner
0
194
Member Avatar for winbatch

STL vector objects have their own default capacity, which is implementation dependent. You should be able to determine this value rather simply. Something like this should do. vector<int> v; cout << "default capacity of vectors in my STL implementation is " << v.capacity << Of course you can specify a …

Member Avatar for Lerner
0
265
Member Avatar for ricciola

Within the file you are using all data is binary. When the file data is read into your program, your program converts that data into whatever it's been told to convert it into based on what variable is going to hold the information in the program. To concatenate to variables …

Member Avatar for ricciola
0
218
Member Avatar for smicer

If you want (or need) to slug it out yourself instead of using someone else's solution, one way is to represent the very large number using an array of char (ie a string). Each char represents a place holder in the actual int. The trick then becomes how to convert …

Member Avatar for Lerner
-1
153
Member Avatar for bigwillis234

If you post code (using code tags) someone may be willing to take a stab at helping you. Without posting code it's like asking "how can I reduce the time it takes me to file out my tax return?".

Member Avatar for Rashakil Fol
0
302
Member Avatar for atrusmre

if x modulo y equals zero then x is evenly divisible by y. Modulo operator is the % sign. Works only for integer types.

Member Avatar for Lerner
0
119
Member Avatar for saifo

Please use code tags when posting code. That involves putting the word code in square brackets before the first line of code and the snippet /code in square brackets after the last line of code. That will preserve your indentation and make it much easier for us to read. Just …

Member Avatar for saifo
0
206
Member Avatar for gunalan

Well, you might want to put in some parenthesis to be more specific about your intentions. Otherwise, unless you are very certain of operator precedence rules, you can easily end up with a miscalculation because of an operation being done out of sequence when you have such a complicated equation. …

Member Avatar for Lerner
0
216
Member Avatar for simon126

It's seldom the case that there is only one way to write a program. Your professor my require to use a do/while loop as a learning exercise, eventhough from a general programming standpoint there are other ways. Also, a do/while loop makes a lot of sense in this instance because …

Member Avatar for Lerner
0
261
Member Avatar for este77

alternatively, forget you are writing this for the computer for a while and use a pencil to write down what needs to get done when. When you can write it out on paper then you can change it into code. For example, you could start real general like this: enter …

Member Avatar for Dave Sinkula
0
165
Member Avatar for christyj5

Please provide several lines from the file and how it is to be interpretted. I suspect you are setting up the arrays incorrectly. For example, if the file looks like this: ABC BBA CBB then [code] char quiz[3][3]; for(i = 0; i < 3; i++) for(j = 0; j < …

Member Avatar for Lerner
0
465
Member Avatar for Acidburn

You assign memory to buffer with the new statement which makes it capable of holding a string but you don't actually assign a string to buffer. Therefore buffer is empty, meaning it isn't a null terminated char array. I'm not sure what behaviour to expect when you send an empty …

Member Avatar for Lerner
0
223
Member Avatar for djbsabkcb

You have included cmath twice, but that's not likely to cause the problem you describe. When programs compile, but then don't run appropriately, it is harder to debug them. In this case the syntax of obtaining file names and associating them with files, etc. seem appropriate. Therefore, I would try …

Member Avatar for djbsabkcb
0
1K
Member Avatar for SpS

If you don't want to go graphic how about extending the vector STL class to handle mathematical vectors/matrices. Or how about writing code to implement a B-tree.

Member Avatar for Lerner
0
198
Member Avatar for plshelpme1

From what I gather, you use a two dimensional array of int (seatx) to represent the rows and columns of seats and the value of 1 to represent empty and 0 to represent taken. To display empty or taken instead of 0 or 1 when displaying seat availability you could …

Member Avatar for Lerner
0
863
Member Avatar for kokopo2

>the program should print the output as 12 is a number. You don't need to convert the string 12 to the number 12 at this stage according the the directions given above. You will need to convert the string to a number if you eventually want to do calculations using …

Member Avatar for Dave Sinkula
0
455
Member Avatar for paladin4service

Many GUI programs don't recognize input as anything but strings. They validate the string input and then convert the string input into a type that is appropriate for calculations, do the calculations, then display the report again as a string. If that's the way your system works, then there are …

Member Avatar for Ancient Dragon
0
249
Member Avatar for konacious

Yes. So, IF you type in two sentences, the first of which ends in a period and is followed by two spaces before the next sentence begins, you will increment numWords by 3 rather than by 1, which will cause a discrepancy in numWords. If your input can include this …

Member Avatar for konacious
0
283
Member Avatar for iamthwee

Look for a pattern in your code to figure out how to do this in the generic sense. For examply you start with 1. Then you multiply 1 by 2. Then you multiply that value times three. Then you multiply that value times 4, etc. The last value you multiply …

Member Avatar for bops
0
387
Member Avatar for 3265002918

It's not impossible to solve the system of three equations with three unknowns using C/C++ but it isn't trivial either. The options to do it using a computer running a program written in C/C++ would be essentially the same as if you were doing it by hand, with the syntax …

Member Avatar for 3265002918
0
181
Member Avatar for konacious

You have both syntax as well as logic errors in your code. I have commented as to the syntax errors and I think you'll be able to see the logic errors as you read the comments. [code] void initPlane(char plane[NUMROWS][NUMSEATS]); //remove ; //place { here for (int y = 0; …

Member Avatar for konacious
0
214
Member Avatar for khan_069

Is this something you want to do on your own as a learning assignment or would you be willing to use standard solutions such as the STL set class which guarantees uniqueness of elements entered into the container, has a method that allows you to deteremine how many elements are …

Member Avatar for Lerner
0
122
Member Avatar for NolanVW

I'll try to enter gently (into the conversation of others), but I believe the process could be demonstrated something like this using C++: //variables to write to file int date = 10; char month[12] = "June"; float first = 1.011; float second = 2005.2; //using C++ style file I/O ofstream …

Member Avatar for NolanVW
0
1K
Member Avatar for JoBe

>am I correct in assuming that where ("aa") is written, there could/should be a link like this in for example: C:/MyPrograms/Microsoft Visual/ ... ? Yes, any valid path can be used as a file name, and sometimes the full path must be used, for example, if I remember correctly if …

Member Avatar for Dave Sinkula
0
448
Member Avatar for crazyfans86

The C and C++ languages do not have native graphical capabilities. To do things other than bar graphs oriented either horizonally or vertically with the bar made up of a series of characters, (that is histogram), you need to use a third party library such as Windows API or even …

Member Avatar for BountyX
0
293
Member Avatar for Judas

Let me see if I understand what you are trying to do. You start with a C-style string variable set to roomname. You then concatenate hallway to that string to create roomname hallway on the first pass through. You then want to reset the string string variable to roomname so …

Member Avatar for Dave Sinkula
0
1K
Member Avatar for webempress

Type Text is probably a string of some sort, rather than type char per se'. This then becomes similar to converting type int to a string, whcih may be in a FAQ somewhere. In any event, I'd try using a stringstream (C++ style) or sprintf() (C style) to convert the …

Member Avatar for Dave Sinkula
0
365

The End.