949 Posted Topics
Re: I doubt that you'll get what you want just by asking. We help people who want or need to program in C, and are able and willing to work. If you want help, you'll need to get cracking, and post some work up. Ask specific questions about whatever has you … | |
Re: The getstr function is dodgy. scanf() is looking to take in just one char, but the user is trying to enter a string. And scanf() has to have an enter key to assign a value (buffered input). fgets() is the function that immediately comes to mind for string entry. Overflowing … | |
Re: One obvious problem is that the program closes the files AFTER the program has ended <so it's not closing the files, at all>. Your IDE MAY close the files for you, but that's your IDE, not your program. I don't see anything wrong with the rest of the program. Exclusive … | |
Re: Think of %l as just ONE thing - a format specifying the data type to be printed. So what's left is just one % char to print. | |
Re: The outside sources may have become scarce, but you can always try and work it out, yourself. The language is not the problem, but the logic you will need, to do this -- that's what you need. Do you know how to transform this data from one type to the … | |
Re: What have you considered or tried? Post up what you have done, and we'll help answer any questions we can. | |
Re: Best explanation for it is on Wikipedia. Bookmark Wikipedia if you haven't done it already. They have a huge amount of programming pages, and a portal just for algorithms, IIRC. | |
Re: Welcome to the forum, Anzoo! ;) Here's the way to use the forum - give your assignment a good try, and then post your try. Tell us what has you stumped. If we don't do that, we become "homework coders" for everyone (or so it seems), and the students can't … | |
Re: It all depends on how fast you need to develop the program/robot, and how fast you need the program/robot, to respond or to perform. Python would undoubtedly be easier to develop than C or C++, but you'll never get the responsiveness in Python or Java, that you would get in … | |
Re: The factorial function doesn't have a prototype in the program. My compiler wouldn't complain about this, since factorial() is above main(), but strictly speaking, it's bad form. Does your compiler want another include file added to support long long int's? | |
Re: if() and while() and for() statements all have a test. The answer to that test will be either zero or non-zero. A zero answer means the test result evaluated to false. A non-zero answer means the test result evaluated to true. [CODE] if(0 < 1) { printf("\n Zero is less … | |
Re: int width = 7; Then replace your blank printing loop with: [CODE] for(k=width;k>(i*2);k--) { printf(" "); } [/CODE] Note that the loop above prints just ONE space char, at a time, instead of two space chars, as the current loop you have, does. | |
Re: Use while((fgets(bufferName, sizeof(bufferName), filePointerName)) != NULL) { instead. Testing for the end of the file has become quite unpopular (and deservedly so), for just this reason (among others). Don't use it. | |
Re: Watch your dates, Acer - this thread was from 2004. <Yikes!> ;) And Welcome to the forum, Acer! | |
Re: Easy does it Ellenski. If Ancient Dragon recommends something, I'd read it. He's one of the most knowledgeable posters you'll find. I, on the other hand, know just about zip about BST's, but clearly you need to adjust the left and right pointers to the nodes that are linking to … | |
Re: If the compiler's error or warning says the function should return a value, then I'd try and have the function return a value. ;) Prototype your functions, and make sure the actual function return types, match the return types of your prototypes. | |
Re: Sorry, you need to show some work on this. Just posting your assignment and waiting around for some shmuck to do your homework for you, doesn't meet the requirements of the board. I find it impossible to believe that you can't figure out how to calculate the charges and time, … | |
Re: I refuse to answer, on the grounds that you should be enthusiastically TESTING this yourself. ;) Put down your latte, take 30 seconds, and test it, FCOLoud! | |
Re: I can't tell you, but I can tell you how to troubleshoot it: 1) Copy down the EXACT error message, for reference 2) comment out the calls to functions, one by one, until you find out which function is causing the error. 3) going into that function - comment out … | |
Re: For a beginning student, TC can work fine. There's no doubt TC is the easiest and the fastest IDE to set up, and get help in. It works fine in XP and all earlier versions of Windows. Naturally code blocks or visual express would be better choices, but they can't … | |
Re: You should return the index to the number, not the number. Then use the index, in main(), to print out the number. Free the array whenever you no longer need it. And you don't need to cast the return from malloc, in C. | |
Re: I surely don't like it. I can see having two returns in a function. One is preferred, but two is OK. Four returns in one function, is not OK. mid should be set in ONE line of code, outside of the if else statements instead of being inside, in two … | |
Re: continue statement is designed for loops (for or while, or do while). Wouldn't make sense to try and use it in an if/else statement. You can have a "do nothing" in an if statement, however: [CODE] if(numberOfApples > 1) ; //nothing gets done else printf("\nNo apples here yet!"); [/CODE] Good … | |
Re: You'll find this much easier if you use a bit of top-down design here, especially: [B]Put Off The Details[/B] Get the basic control and flow working, then get your details going, [COLOR="Red"][B]LATER.[/B][/COLOR] You have a source file, and it has 30 names of other files in it, or what? Because … | |
Re: Sorry Libathos, that sounds a little too virus-like/malware type programming, for me. "Beware the Dark Side of the Force", Libathos. | |
Re: Welcome to the forum, Chrysanterus! Always better if you start a new thread for a request. I've zipped up all the example programs that I got with Turbo C. You can d/l the self extracting file from Swoopshare, here: [url]http://en.swoopshare.com/file/71f8ef6d5a664112a30d0c420ec58218/TCexamples?tags=TCexamples&lang=en[/url] note that this is from an early version. Since then, … | |
Re: You'll certainly want to open the files in binary mode. First thing I'd do is write a function that will open and copy a solo and regular JPG file, and make sure it can be then viewed OK. Then, I'd see about getting the smallest *.RAW file I could, with … | |
Re: That's over my head, but this file seems loaded with info - it's not free, however. :( [url]http://www.sciencedirect.com/science?_ob=ArticleURL&_udi=B6WGK-4N7S53V-1&_user=10&_coverDate=07%2F31%2F2007&_rdoc=1&_fmt=high&_orig=search&_sort=d&_docanchor=&view=c&_searchStrId=1418901380&_rerunOrigin=google&_acct=C000050221&_version=1&_urlVersion=0&_userid=10&md5=405e0005965da2ca0c53dd9d9bda1f77[/url] Gotta be the longest url I've run across in a long while! | |
Re: You need to remove the return of float from your function (make it void), and remove the print in main, asking for a string. gets() is NOTORIOUSLY unsafe - use fgets() instead. And indent your program, so it makes sense to read it. It's a mess* this way. The closing … | |
Re: My suggestions: 1) change the value for alive or dead to 1 or 0. The printout can easily show a dot for 0, and 'X' for alive. 2) Delete the defines in red. 3) Instead of 'V1', etc., name your directions something you can intuitively associate with the 8 directions: … | |
Re: Welcome to the forum! You obviously need to add some logic here - hardly a surprise that month needs to be set to 1, along with the day, at the end of the year: [code] if((day == 31) && (month == 12)){ printf("The date of the next day is: %d/",nextday); … | |
Re: By "project", do you mean a "final year" type of programming project, or do you mean a project inside your IDE (your compiler)? And welcome to the forum! ;) | |
Re: This is another of those "your assignment is to eat, but you can't touch the food with anything", kind of an exercise. ;) Which means the lecturer will have given you hints (maybe subtle, maybe not), about how he/she wants you to proceed with this. Review your class notes, and … | |
![]() | Re: You defined your struct, and made a pointer to it, but I don't see an actual struct being declared. Also, scanf() needs a getchar() after each instance, if you want to keep getting char's from it. Need to pull the newline char, off the keyboard buffer. ![]() |
Re: Obvious errors. If you want a nice round clock face, you need to work with a graphic mode console, not a text one, and then use math.h to calculate the number of degree's or radians needed between numbers. If you want a square one like the red one at the … | |
Re: You wind up comparing a char, to a string in words - that won't work. In your call to findchar(), I'd just pass the one word that you will be checking, rather than the array. You seem to be confused about that, so: words[random_word][] should do. ARRSIZE sounds wrong, also. … | |
Re: Check out your help index for "Virtual Keys" or "Virtual Keyboard". If you have nothing there, go to the MSDN library - it is definitely there, with an example program, as well. | |
Re: You opened the file for writing. I'm guessing it should be closed before you call CopyFile. Adding code tags (click on the [CODE] icon at the top of your editing window), improves your code's readability, greatly. | |
Re: Are you trying to change a CONST value? If you add something to the file name, you are renaming the file. If you just want to "touch" some file values, I believe you do that through the FILE pointer struct, associated with that file name. by "touch" I mean the … | |
Re: That is a different problem than what you posted, above. Extracting m characters, beginning with the nth character, means just that. It does NOT mean "scan the char string for some char and when found, extract m characters". If you want to post code, PLEASE click on the [CODE] tag … | |
Re: I am NOT going to tell you this answer - you would hate that, surely. if(hint, hint), EITHER the multiplicater, OR the multiplicand, (but not both!) are negative, what will you have to put at the very end of your function, to make the logic correct? C'mon! ;) | |
Re: The fastest way to do this, is to: 1) Get your basic FLOW and calculations of the program, working correctly. At first, just display it on the screen - it's faster, and so easy to go back AFTER you have the basics right, and change the printf() statements, to fprintf(), … | |
Re: It will compare the two strings: strcmp(string1, string2); If the return value is greater than 0, string1 has sorted higher than string2. If the answer is anything less than 0, then string2 has sorted higher. [B]string1 [COLOR="Red"]>[/COLOR] string2, return [COLOR="Red"]>[/COLOR] 0 string1 [COLOR="Red"]<[/COLOR] string2, return [COLOR="Red"]<[/COLOR] 0; [/B] You can … | |
Re: Assign the largest number initially, to the value of the first element of the array. Assign the 2nd largest number initially to INT_MIN (your compilers macro for the least possible value for an integer. That makes the "mouth" for trapping the numbered values you want in the array, suitable. (Your … | |
Re: This is Turbo C guaranteed! ;) [CODE] /*Here is the code I wrote up to solve your problem. c Syntax (Toggle Plain Text) */ #include <stdio.h> #include <stdlib.h> int main() { char two_digit[3]; int digit; printf("Enter two digits: "); fgets(two_digit, 3, stdin); //Accept size-1 (in this case, 3-1 which is … | |
Re: I don't believe there is a problem doing this, you're not bringing your pointers or member operator on down to the right level. Using the dot operator, I would say: parent.nameOfField.nameOfChildStruct.fieldIwant You can do the same idea with pointers, of course. | |
Re: fgets() DOES limit the amount of chars you can put into your buffer, but you never made your collection of chars in your buffer, into a legitimate string - it has no end of string marker. #include <stdio.h> int main() { int i; char buff[25]; buff[sizeof(buff)-1]='\0'; //setting the end of … | |
Re: When you see code like this, why not simplify it? [CODE] if(n == a[i]) { pass++; } else if(n > a[i]) { low = i+1; pass++; } else if( n < a[i] ) { high = i-1; pass++; } to just: pass++; if(n == a[i]) { return the i; } … | |
Re: You're on the right track. If you can't use an array, you can just assign variables for each digit. Here's an example of how to handle 0-4 digits. [CODE] #include <stdio.h> int main() { unsigned long n; //let's the number be rather large int i, zero, one, two, three, four; … | |
Re: You don't mention the most important part of your program - does it work correctly? Everything else is secondary. Assuming it does work properly, then what deficiency do you notice or what is it that you want to improve? With a palindrome program, if it's accurate with all kinds of … |
The End.