1,608 Posted Topics
Re: 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++ … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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) … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: >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; … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: You need to deal with the back pointer in each of the new nodes you are creating. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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?". | |
Re: if x modulo y equals zero then x is evenly divisible by y. Modulo operator is the % sign. Works only for integer types. | |
Re: 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 … | |
Re: 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. … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 < … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: >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 … | |
Re: 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 … | |
Re: 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 … | |
![]() | Re: 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 … |
Re: 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 … | |
Re: 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; … | |
Re: 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 … | |
Re: 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 … | |
Re: >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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … |
The End.