949 Posted Topics
Re: You don't want variables up above main() (Global), generally speaking. They are TROUBLE! Prototype your functions above main() - YES! Same with structs. That way, any function can easily create a local struct, for temporary work. Passing your variables to functions, ONLY if they need them, and then pass them … | |
Re: You need to put some work into your query. Tell us what input gives you what for the error. Also, tell us what function the problem is in. That's easy baby steps to fixing programs, and thats a skill you will have to develop, in any language you work with. … | |
Re: Check Google and YouTube for DS and Algo classes (either past classes or upcoming in the Fall). Uni's in the past with classes include MIT, Harvard, Stanford, etc. In some cases you can actually enroll, but you can also just watch the video. Many particular DS's and Algo's are shown … | |
Re: Your switch statement only deals with numbers up to nine. As Moschops suggests, you need to deal with each digit of the number. One easy way to do that, is to change the number, into a string of chars. Then deal with each digit in the array of chars. ![]() | |
Re: LOTS of videos explaining minimax algorithm, on YouTube: http://www.youtube.com/results?search_query=minimax+algorithm&oq=minimax&gs_l=youtube.1.9.0l10.892043.894777.0.905494.7.7.0.0.0.0.170.1016.1j6.7.0...0.0...1ac.1.11.youtube.r8wYIglheVM | |
Re: Instead of explicitly printing every every * with another line of code, you want to use loops and if statements, etc. Think more like this, in pseudo code: get the height and the width of the box, from the user for each row move the cursor along the width of … | |
Re: Would you post the program? I'd have to see how the program is set up to receive input. Also, I want to be sure you actually wrote the password program. I want to avoid even the appearance of helping someone crack a password. | |
Re: Using Pelles C, you should use the compiler in the IDE. Whatever options you want, you can change the compiler flags being passed to the compiler, right in "Project" ---> "project options". That way you don't have to keep keyboarding in a bunch of flag options. I use the default … | |
Re: You want the "tightest" code which adds a few variables, and multiplies those values two times? The assembly code the compiler generates will vary, but the execution time and overall size, will be remarkably similar. There aren't many ways a compiler will take to add or multiply. If you are … | |
Re: Showing once again why volunteering a program, without the original poster doing any work whatsoever, is a bad idea. Whether it's homework, or a problem solving website like SPOJ or Euler Project, having us code up a gratis program for them, is just wrong. They did none of the work. … | |
Re: Any time you venture out into the "weeds" of undefined behavior, the results can be odd or just what you might expect. The point is, why bother? It's an unproductive line of inquiry at best - a complete mockery of the standards of the C language, and your ability to … | |
Re: Make your first two elements in a stack, and then compare the addresses they have. | |
Re: Your printf() line of code is a great example of programmers being oh-so clever, while ignoring the virtue of clarity in their code. If you had written that line of code for me, as your employer, I would give you one warning - and on the next occassion, FIRE YOU, … | |
Re: Try Super sed. (for Windows command line, I believe). http://sed.sourceforge.net/grabbag/ssed/ If you have a 2D char array, all the editing can be done in only a single row of text. This array only needs to have a few extra rows on each side of the visible text rows you see … | |
![]() | Re: I strongly recommend you switch to the Pelles C IDE & compiler. It's based on the llc compiler, iirc. I use it for all Windows based C programming, and couldn't be happier. Any questions I have about it, get answered here: http://forum.pellesc.de/index.php quickly and authoritatively. :) |
Re: If you can use character code changes to effect this, that would be easier. This is a "roll your own" approach. Think of a one-to-one translation, using an array. The letters and digits in the hex string, all have a value - A is 65, B is 66, etc. Of … | |
Re: What is the problem stopping you? If you don't know how to multiply, sign up for a remedial math course, and drop programming for now. If you thought someone would just happily do your homework for you, please think again. You learn nothing without working at it. We HELP people … | |
Re: [QUOTE=codewriter2010;1281157]Your sorting is used for only integer,i need a quick sort which is generic to all basic types such as int, float, char and struct types[/QUOTE] What you are looking for is qsort(), and it's part of the C standard library. The good part of it is that it handles … | |
Re: You put in a string of words as ONE string. The strcat() I don't believe was necessary or desirable. But you're expecting an end of string char, for every word, and there will not be one for every word. There is just one (originally) for the entire string of words. … | |
Re: This is an exact copy of another request I answered on another board - so I'd change it around to avoid suspicion of copying. First, in get_file(DATE a). Change it from a void function, so it will return the DATE a, to the calling function: DATE get_file(DATE a) //and the … | |
Re: Daniel honestly - you can think of a way to code up a loop and zero in on a square root of a number - I know you can. | |
Re: You ask for help, but we don't have the info from you, to help you. I know you don't want to spend the time to write up the specifics, but really, we have very little idea of what command does what, and how much, on your robot. You haven't even … | |
Re: Line 23, remove the & from that line. rename struct temp tempSt, and make changes so it's clear which is which. | |
Re: Actually, it's in Windows 7. Open a command window and type xcopy /? for all the info on it. Obviously, naming the files you want to move, and where you want to move them to, is critical. That being said, I believe you'll enjoy programming it in C, instead, and … | |
Re: Because it's illegal in C. This has been answered for you in other forums already, in detail. | |
Re: Do NOT use feof() - it simply doesn't work the way a human thinks it should, and it will goof you up every time. There are three ways: 1) while((fgets(myCharArray, sizeof(myCharArray), filePointer)) != NULL) { //your code to work with myCharArray[], as you need to //fgets always puts a newline … | |
Re: Digits sort lower than any letters, so ascending order would start with 234bk... etc. Descending order is OK. Normally, you'd want a separate function for sorting, but C also has qsort() as a very capable sorter. Post up some code so we can see how the program is organized. | |
Re: You'll have to recurse one time more than you want to, to find the next char, THEN if it's 'I' don't remove the 'b' you were checking out on the earlier depth. Otherwise, remove it. Likewise, if you recurse one depth and find the end of the string, then don't … | |
Re: If you want to work with larger int's, move to a 64 bit system and compiler: 18,446,744,073,709,551,615 is the max integer (unsigned long long int) Or use an array, and treat it like every element of the array, is a digit in a BIG integer. It is challenging, but not … | |
Re: @ Eivnay: Yes. That is a limitation of any Turing style computer. On timing programs: The early PC's had the timer running off the PIC chip (programmable interrupt controller), using 1/3rd of it's clock sweeps. That gives decent timing IF you have a DOS or real time operating system, not … | |
![]() | Re: The newline is indeed picked up by fgets(). If you think about it, the newline is THE thing that creates or defines a line of text, isn't it? This will get rid of it: //add to your include header list: #include <string.h> //in your function where you are reading the … ![]() |
Re: Your array to hold the file's contents needs to be 2D (rows and columns): array[rows][cols]. Each time you want to save a row, copy it to array[rows] - that serves as the array pointer for that row. (In C, 2D arrays are arrays (rows) inside the larger array.) The general … | |
Re: I don't mean to alarm you, but your program doesn't have a cost function. ;) | |
Re: Your robot will have to have a micro controller, if it is to be controlled by electronics. Since you "don't know about micro controllers", you will have to learn how to program them, because the controller (as the name implies) controls the robot, at a very low level. We can't … | |
Re: There is no worse description of a probem than "it's just not right"! :( Give a specific description and an example of the problem. "Just not right" ---> WTF! | |
Re: To print in landscape mode, you can either use a printer feature, or a program like you're talking about, here. If the printer has a landscape feature, then obviously you want to just send it the code to switch it into landscape mode. That feature is not available on all … | |
Re: Check out fseek() to smartly maneuver around a file. Any time the records of the database are not fixed in their size, (that is, all the same size), you will find it more difficult finding your way around inside a file. Conceptually, there is a tiny buffer, than can be … | |
Re: When you have a string of words - here a word, and then it's definition, on the same line, you want to use fgets() and put the entire line into a char array (I use "buffer", all at once. The newline will be included on the end of the buffer … | |
Re: I don't fully understand the problem, but it sounds quite interesting. I went to codility.com, but they don't have their problems listed like some of the code challenge sites (Euler, Code Chef, SPOJ, etc.). | |
Re: You have an int array, and you have an array of int pointers? They are the same size, right? Then it's straight forward: Before you sort anything, you assign the address of the pointers to each array[index] number, in turn. In your sorter, you will make all your comparisons using … | |
Re: The Aussie's and their Ant clusters: [url]http://cellar.org/showthread.php?t=24345[/url] | |
Re: Yes, working with the data inside an array is preferred. Once you start changing data in a file, it's really easy to muck up the file - and then garble the data. The general technique is: 1) put the data into an array 2) change the data as you want … | |
Re: Pare it down to a smaller memory size AND/OR enlarge the size of the page, if possible. Without seeing the code, it's impossible to say more. | |
Re: Why not read through the subjects of other projects, and see if that doesn't spark a bit of interest in you. Imo, it has to be something you're interested in. Also, read through the science news (Google it), and again, see what catches your eye. Driverless cars? A few are … | |
Re: The more common convention would be 1, 0, or -1. The standard may allow any value > 0 < 0 or 0 (as is seen with strcmp(), a very similar function). The negative value in one, and the positive value in the other, is a problem however. Could it be … | |
Re: I can't tell by looking at your code, what's wrong. My suggestion is you alter your code temporarily, and have it put out EXACTLY the same pic. Now you can use utilities like "fc /b filename filename" (but check it with "fc /?", because I haven't used it in a … | |
Re: No, the code is not correct, and it's not Windows problem. Listen! You need to add the ampersand for your scanf()'s where the variable is not a pointer (or the name of an array). printf("\n\t\tEnter SSS contribution: P"); scanf(" %d",sss); //add an ampersand: &sss printf("\n\t\tEnter PAG IBIG contribution: P"); scanf(" … | |
Re: The only thing the program is timing is the run time of the issorted(), being called over and over. And we have no code for issorted() here. You might be able to optimize the sorting function, but not without seeing the data being sorted. Qsort is not the fastest sorter, … | |
Re: Code is useless at this point. Not your code, but ANY code. First, before ANYTHING ELSE, get the right algorithm. And you don't have it. No amount of optimizing later will overcome the problems of a poor choice in the algorithm. And this is the algorithm you should be studying: … |
The End.