949 Posted Topics
Re: Pretty simple to code this up, why not try? [CODE]while there are more letters in the string take each letter and put it into a char words[50][50], incrementing j, unless it's a space or punctuation char. (use ctype.h and isalnum() ). In that case, increment i and start a new … | |
Re: Use a good sized char array[100] or so, and fgets(array, sizeof(array), filePointer), to put one row of data into the char array. Now, in a for loop from array[0] to array[strlen(array)], count up your spaces and add 1 - that is how many numbers you have in that row. now … | |
Re: I don't like that code for this assignment. There are no structs, and there are no functions. It might work, but it's not what you need. how about having a prototype of a struct with 3 words: [CODE] #include <stdio.h> #include <string.h> //for strstr() #define SIZE 100 typedef struct { … | |
Re: You have been given the same answers in two different C forums, I hope that's enough cross posting on this subject. | |
Re: Include string.h if you haven't already, then use strstr() which will return a pointer to the first letter of your sub string. Now using that address, you can use memset() or memmove() to change the contents of the larger char array, to some sentinel value, blank spaces, or whatever you … | |
Re: Welcome to the forum, udinnet! ;) Tell us a little about this program. Is it meant to find one solution, or all the solutions? What kind of run times are you getting for 8 queens, on an 8 X 8 board? On what kind of system (cpu speed)? Do you … | |
Re: After 15 posts, you should know to ALWAYS use code tags around your code. I'm always a bit amazed by posts like this. You have your program, why not test it? It's VERY difficult to look at code and see if it's got a bug or not in it. An … | |
Re: In C, you read a text file line by line, using [CODE]fgets(charArrayName, sizeof(charArrayName), filePointerName);[/CODE] Which will automatically insert the whole line of text, into your char array, including the newline (and the end of string char: '\0', after that. (If room allows). [CODE]while((fgets(charArrayName, sizeof(charArrayName), filePointerName)) != NULL) { //your code … | |
Re: I applaud your perseverance, but that is not an acceptable way to program. Use arrays and loops, especially for and while loops, to cut your program down to 1/10th that size and number of separate variables. | |
Re: Just a repeat of the answer I gave to your post in the database section: I would export this data, in text format, to a file. Then write a short program to make these changes. Then import the data back into Excel. | |
Re: Hard to explain a crypto program in a forum post. This has a lot of info, a sample encrypt and decrypt function in C, and links to a lot more info on TEA. [url]http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm[/url] | |
Re: Normally, you would sum up via row like this: [CODE]for(row=0;row<MaxRows;row++) { for(col=0,sum=0;;col<MaxCols;col++) { sum+=Array[row][col]; } printf("\nThis row sums up to %d", sum); } //Now you just "turn it sideways", to sum by column: for(col=0;col<MaxCols;col++) { for(row=0,sum=0;;row<MaxRows;row++) { sum+=Array[row][col]; } printf("\nThis col sums up to %d", sum); } [/CODE] Give that … | |
Re: fflush(stdin) is like trying to flush your kitchen sink. Flushing only works on output streams (like the toilet in your home), not on input streams, like your kitchen faucet. ;) | |
Re: The way redirection work on Windows is simple: If you have a command line like this: programName <fileName Then the standard input (keyboard generally), will be replaced by a stream input from the fileName. Obviously, if you don't have a file named "fileName", in the same directory as your program, … | |
Re: Instead of the simple if(char == space) logic, (which obviously can't handle multiple spaces), how about this. inword = 0; changes to inword=1 when you find a word. When you leave a word, it goes back to 0. First letter you run across, you set it to 1, and increment … | |
Re: Standard practice would be to sort such data through an index or pointer array. I'll describe how to use an index: Make an int (unsigned long if needed), with at least as many elements as there are rows of data in the file to be sorted. Now initialize the index[] … | |
Re: I've never heard of "Flames". Since you've had no responses, I suspect others haven't either. What should your output be, and what have you tried to fix it, so we don't have to repeat it? Thanks for using code tags. ;) | |
Re: I know two verses of a song (in a function), but I need someone (another function), to tell me which one to start singing. How could that be done? Have you ever heard of PARAMETER City? Lovely place. Post up your map and bring your compass, and we'll get you … | |
Re: Yes there is such a tool. "Valgrind". I'm unsure if it works without running the program you want to test, however. | |
Re: Viruses are a large, and constantly changing area of study. They may attack: 1) Through your browser (common), but any running program that can be "hijacked", including any part of the operating system, including the services, etc., will do nicely. 2) By tricking you into downloading a trojan, which is … | |
Re: When you run across the merry prankster who convinced you to use that sorting code, kick 'em in the a**. I've looked through this a few times, and it's a toss up between cussing and laughing, I can tell you. ;) By all means, narrow down the problem! The worst … | |
Re: If you'll post up a small example of the file, as an attachment, we can show it. I'm not sure what is included in Code Snippets. | |
Re: [QUOTE=makibao;1492053]PLease help me !! how can i uppercase the half only of the string and the half is in lower case??[/QUOTE] include string.h, and ctype.h, and use the strlen(string) function to help you know the length of your string. Then divide by two. Add one if the length is odd … | |
Re: If you want any respect on a programming forum, I'd change your forum handle. Outside links to "alice", won't go over well, either. | |
Re: Welcome to the forum, Happy! ;) Tip: Next time, start up a thread all your own, instead of posting your problem, in another thread. So what have you got to sort? Can you post a little example of the data, or describe it? Also, how MANY things do you have … | |
Re: A couple big time savers: 1) You only need to check a number up to (and including) the square root of that number. If the number is prime at that time, then it's prime. 2) increment your loop by 2 for the numbers to be checked for primeness. Even numbers … | |
Re: So, if you can read, what's the problem? The answer is right in front of you. ;) | |
Re: First, don't use feof() to test for the end of file - it doesn't work as you think, and you'll frequently get doubled last data. Second, to ignore a row of test, just pull it into a variable that will be immediately overwritten, outside of the overall loop that you … | |
Re: Probably won't work, because the web site will only allow you to enter a password attempt 3-5 times. Then you're out of play for an hour or more. And no, it doesn't sound like a homework assignment. ;) | |
Re: You're letting j run outside the boundary of the array on the last loop. Keep it < 5, always. Also, < should be > in your comparison, if you want the largest number. Otherwise, you'll get the smallest number in the array. | |
![]() | Re: It's NOT a problem with LCD monitors. I use turbo C 1.01 all the time, and have an LCD monitor (Samsung), and it's fine. The OUTPUT is the same, an LCD monitor just uses it for a different device, downstream. It's also NOT a NVidia card compatibility problem. I have … |
Re: All operators (and thus all mathematics operators), are tokens. Your compiler help should have a list of them. | |
Re: Welcome to the forum, Antichix! ;) The way we roll here, is you get started on your program. Then, if and when you get stuck on something, you post up and we'll try to help. We're SO not a "do your homework" or "get you started" kind of a forum. … | |
Re: You need to get this started. THEN if you have some specific questions, post up. Asking general questions before you get started, it sounds like you want somebody to do your assignment for you. You need to take the lead on this. I know Wikipedia has a lot of info … | |
Re: This is THE most complicated, and most verbose flood fill function, (because that's all it should be - one function), I've ever seen. You've made a serious error in how you program: 1) You've written a lot of code, but obviously didn't do any testing along the way. 2) So … | |
Re: That's a very odd sort block of code. I'd dump it. Here's an easy one (this is substitution sort and should be used for small and medium sorting jobs). [CODE] Where SIZE is the size of the array with data you need sorted where i and j are integers where … | |
Re: fgets() is the more robust and generally better input function to use with the user. In this case, and just as an alternative, a format specifier for scanf() might be used: [code=c] scanf("%[^\n]s", str2); getchar(); //get rid of the newline char [/code] Which tells scanf() to continue taking input until … | |
Re: You need to process each keystroke from the player, quicker. Since you have conio.h, you should be able to use kbhit() to detect if a keystroke has been made. Windows has it's own equivalent way to detect if a key has been pressed, and your program needs to use ONE … | |
Re: I answered this question for you, in the other forum. Now that you're cross posting, I won't bother henceforth. You're wasting our time. | |
Re: Do you need to put an end of string char into buff[0]? '\0' Yes - even if you don't NEED to, you need to, ;) and I would. Just good defensive programming when dealing with different strings, going into the same variable. | |
Re: main() is the point that the program jumps to when it starts running. It's like the starting line of a race. While some races are handicapped and have more than one starting point, the computer is not so inclined.;) As L7Sqr mentions above, there is nothing like a good test … | |
Re: I'm just curious - what would you guess that "lib" is short for? ;) I mean really, take a guess! When you're ready for a bitchin' C IDE and compiler, FREE! and includes support for conio.h (like Turbo C), but works on 32 and 64 bit cpu's and OS's, like … | |
Re: It's easier if you create the array in the calling function, then pass it into the called function as a parameter. Upon return from the called function, the array is still valid, and has the data you want in it. You can do it the other way, but it's more … | |
Re: If statements are needed because some comparisons involving the row of char's is needed. There is a simple way, to do it though. (Loose code to emphasize logic) [CODE] char buffer[100]; //nice and big :) fgets(buffer, sizeof(buffer), filePointer); //put the whole row into the buffer if(first char in buffer is … | |
Re: Sonuja, we aren't interested in "providing examples" and explanations for SQL access. What we do is help you with your C code, if we can. You need to put in the work to first, get a start on your code. Then post it, and tell us what's gone wrong or … | |
Re: Selection sort has nothing to recommend it, *except* it makes the absolute minimum number of comparisons. Other than those rare times that comparisons are inordinately costly, it's not a sort to use. The fastest general purpose sort on Windows (since Windows 2000), is to use the system sort, with a … | |
Re: I'm intrigued, and finding the country would be easy, but the phrase "plain text substitution MOD 78" part, just won't let my head wrap around this problem. There must be some little tidbit of info more -- c'mon, spill it! << bright light, 3rd degree regards >> ;) | |
Re: Welcome to the forum, Nurkan! ;) The way it works here, is YOU need to show some work on this program, and post your code up. Tell us what is giving you problems. Then we try to help. We are not a "homework done for you", kind of forum. | |
Re: The directory where the graphics driver is located. If you put these files into the current BIN directory, then just use an empty string there: "" You should not have a $ in your parameter as you call initgraph(). That $ should be replaced with an ampersand: & instead. Oh! … | |
Re: malloc(SizeOfArray) is part of stdlib.h, and allocates memory "as is", in the amount you request calloc() is also part of stdlib.h, and allocates memory which has been set to zero or '\0'. Both of these return a valid pointer to the allocated memory, if the request was performed, and NULL … |
The End.