949 Posted Topics
Re: "archive" is a string, and so scanf("%s", archive); is correct. Remove the ampersand from in front of your "archive", in that line of code. Same is true for "original file", in line #9. Remove the ampersand. The address will be correct, but the pointer will be of the wrong type. … | |
Re: Don't you have documentation that gives you the info like this? Since your question is about a hardware problem, I would ask it, in a hardware or embedded forum. Although I'd like to help, I am not familiar with that hardware. | |
Re: You could include <stdlib.h> and then malloc the memory for buff[]. When you no longer needed it, you could then free(buff). That would save a lot of the static memory space, which is much more scarce than heap memory, (where malloc() gets it's memory for you). | |
Re: I don't have that strptime() function, so I suggest: 1) Use an unsigned long for the seconds' data type. Int may over-run. 2) Once you get the number of days, (or whatever units you want to work with, just do the math yourself: seconds +=hoursPerDay * secondsPerHour, + etc. | |
Re: Consider the number 123: [CODE]while number is greater than 0 one = 123 % 10 number = number/10 //remove the digit in the one's place from the variable number. loop [/CODE] That's all there is to it. It peels off the digits, one by one, from the right hand side. … | |
Re: You'll have to give more info than that! Not related to the "Mummy" are ya? ;) | |
Re: If the test portion of the while(test in here) doesn't resolve to 1 (true), then the inner part of the while() loop will not be entered by the program. So, is t[jcs] > 100, right at the top of the first loop? And somewhere in the while() loop, you want … | |
Re: Change your %f, %s, %s to %f%*c %s%*c %s The %c handles the ',' char, and the * modifier in front of the c, should tell fscanf(), not to store the char. [CODE]fscanf(filePointerName, "%f%*c %s%*c %s ", &myFloatVariable, myString1, mySring2);[/CODE] | |
Re: Did you forget to open the file? ;) [CODE]fp = fopen("myfileName", "r"); if(fp==NULL) { printf("Unable to open the file\n"); return 1; //or use exit() if needed } [/CODE]feof() may repeat your last value, check your return type from fscanf() and if it's less than it should be, break out of … | |
Re: This is a C forum, not a C# forum - move down the forum list just a bit more. | |
Re: Any C tutorial would include this. Google up a bunch, and have at it. If you have a particular question, post up your attempt to do it, and let's see what the particular problem is. There are scores of good C tutorials on the web. Which are appropriate for your … | |
Re: If you want sorted strings, then you have to compare them as strings, not as individual char's. You can see the problem: Abbey should sort out lower than Cathy, but when you are comparing the 'b' in the second letter of Abbey, with the 'a' in the second letter of … | |
Re: Each structure has it's advantages - and disadvantages. It's like what you drive. You'd want a race car for racing (great for speed and handling), but a diesel truck for towing (loads of low end torque), the heavy loads. | |
Re: Perhaps the easiest way of doing this is to use [CODE]fgets(charArrayName, sizeof(charArrayName), stdin);[/CODE] to get the number into a string format. Then just "walk" the charArrayName[] char by char, and add up the values as you go (into an integer variable). For your answer, remember to show it using %d, … | |
Re: Without knowing you, your ability in C and the sciences, or your class, I don't see how we can be of much help. The start must come from you! Look at things on sourceforge.net, and google up other idea's for a project, as well. Talk to your classmates, etc. What … | |
Re: [CODE] #include <stdio.h> #define MAX 20 /* prototype your struct in global scope, above main() */ struct company { float east,north; char name[20],place[20]; }; int main(void) { struct company site[MAX]; //instantiate it in main() - good FILE*file; int i=0; file = fopen("companies.txt" ,"r"); while(fscanf(file,"%s %s %f %f",site[i].name[0],site[i].place[0], &site[i].east, &site[i].north)) == … | |
Re: A few suggestions: malloc() is defined in the include file "alloc.h", not "malloc.h". ;) Without the stdio.h include file, I'm not surprised you're having problems opening files and such. ;) After you malloc() for an array (especially after such a large one), be sure to check the returned pointer address … | |
Re: First, dice IS plural - die is singular. There is no "dices". Sure, you can check each char in the string, to see if it has only certain char's. A check function might look like this: [CODE] /* where 5 is the size of the input array. */ int checkStr(char … | |
Re: @kalai: click on the code tag icon in the editing window, and paste your code in between the code tags. Makes your code easy to read and study, and not look like html text and all squished to the left hand margin. | |
Re: I suggest using chess fonts - google, download them. For a 2D chess board, a console window will be OK, but the visual quality of the pieces really suffers if you don't have chess fonts installed. Using something like Winboard (a chess program interface for chess playing programs without them), … | |
Re: I know Perl is famous for "batteries included", but C is famous for rolling them little batteries right along, as well. ;) If you're going to have to re-write it, consider just using C. | |
Re: I believe what you want is available from the programs that create archives. I'm talking about zip, rar, pak, and all the rest. Google up a website that deals with these archive makers and their algorithms, and dig in. I'd be sure to include Wikipedia in that search. Whatever content … | |
Re: The thing is, there aren't too many programs that don't need a console window, at least. Oh! I know one - a key logger!! No, I won't be helping you. ;) | |
Re: The best way to sort structs, is to NOT sort the structs. ;) Sort an index array of simple int's, instead. This is an example of "sorting" by the index. No data is moved in the process (the original order is retained). All the data can be written or displayed, … | |
Re: Needs a bit of touch up: [QUOTE=TrueCoding;1411656]Basically this is the code but its not displaying my array just some random numbers. [/QUOTE] Let's use MAX of 10, so you don't have to enter lots of numbers yet ;) [CODE] # include <stdio.h> # define MAX 10 int main(void) { int … | |
Re: You probably don't want to hear this, but I feel obligated to say you should move up to a more robust language. QBasic (unless it's the rarer QBasic Pro version), can't even create an executable file. Lots of ways to do this. Maybe something as simple as this: Your data … | |
Re: Thanks for this thread - I love it! ;) Intuitively, you sense that there's a better way (and right you are), but can you find it (and using just the array and indeces)? There is a relationship between i and j that is missing - but what could it be?? … | |
Re: Watch out! The obvious patterns here are looking to bite you! ;) You need to put some effort into this. We don't serve as homework bwitch's. We help people who are willing to show some real effort. | |
Re: Go through the array twice: First time, count the number of times each letter appears. That's easily done using logic like this: [CODE]for each row for each columm ascii[this letter's ascii value]++, coded like: ascii[myLetter]++; end for end for [/CODE] (a 256 element array of type int, will do nicely … | |
Re: Greater than 0, not less than: [CODE] while ((n = fread(buffer,1,sizeof buffer, original_pointer)) < 0) [/CODE] | |
Re: This is not a "do my homework for me" forum. Either show your effort to solve this assignment, or resign yourself to disappointment. | |
Re: What I like to do is call menu() function from main. Menu() is just a BIG while(1) loop, with code to exit when the user requests it. Inside the while loop, it prints the header or banner, the menu options, and has a big switch (choice) block of code, to … | |
![]() | Re: [QUOTE=rafi1082;1404423]hello again i got an assignment i thought i understand it but the every time i read it i understand it differently. my teacher won't explain the exercise. here is the exercise [IMG]http://img42.imageshack.us/img42/8331/37255827.png[/IMG] he also gave an input output example located here [url]http://rapidshare.com/files/434579925/sorted.zip[/url] i'v learned using shmat & shmget and … |
Re: The specifics depends on how your program is structured, which you haven't posted, or described in the detail that's needed. Post your program's code, and give us an example of what you want to do: *input you have *processing you want *output you want Please, not just a description - … | |
Re: Oh hell no! ;) ** Welcome to the forum, Dubery! ** Here's what I want you to do - start with just one number variable, and have the function call itself, until the number is 5, and print it. You won't learn crap by having someone else do the recursive … | |
Re: You haven't yet met Mr. strcmp() I presume? ;) | |
Re: Do you want to use the %x or %X (hexadecimal) format in printf()? [CODE]printf("\n%x/%x \n",numerator, denominator); //or X for upper case letters[/CODE] | |
Re: [QUOTE=raju_devolla;765275]my advice is that for a beginer first get an binary file of an image and read the file and display using put pixel statement in c. As u r going to display black and white image u need to set an threshold value above which all the values should … | |
Re: [CODE] mkdir Creates a directory. Syntax: int mkdir(const char *path); Prototype in: dir.h Remarks: mkdir creates a new directory from the given path name path. Return Value: mkdir returns the value 0 if the new directory was created. On error, a value of -1 is returned, and the global variable … | |
Re: In this code: [CODE] typedef struct point CIRCLE; [/CODE] did you mean: [CODE] typedef struct circle CIRCLE; [/CODE]?? ;) ;) Funny, but I've done that kind of stuff many times, myself. In C, it's always int main, never void main, and with a return 0 at the end. You should … | |
Re: What are your include files for this program? You left them off. | |
Re: Hop in your time machine. Set the date for about 1999. Look into WindowsME, and earlier versions of Windows. After that, the NT kernel came into use from the server line, and that pretty much ended these kinds of shenanigans. | |
Re: The key is in the file names themselves: data-01.txt, data-02.txt... to data-20.txt. Use a char array fname[MAX] to construct each of your filenames: [CODE] char fname[12] = {"data-"}; //leave for for the end of string char: '\0' char num[3] = {"00"; char ext[5][".txt"}; int fnumber; then use a for loop, … | |
Re: You don't seem to have the malloc or the passing array part of the logic, just right. Post enough of the code that we can get an example that is meaningful to correct for you. Those errors have to be studied - post them up with your expanded example. Minimum … | |
Re: Without seeing the code, it's hard to make decent suggestions on how to optimize it. Can you post it, and be more detailed about the +/- error that is acceptable? I'm not clear about what has you stumped either, about creating a look up table. It's a 2D array (frequently). … | |
Re: You could google Microsoft Visual C/C++ Express (it's free), and also, download the video tutorial that shows how to use it (also free). By default, programs with the dot cpp extension are handled by the C++ compiler, and files with the dot c extension, are handled by the C compiler. … | |
Re: Turn it over 90 degrees, and see the columns as rows, and the rows as column. memcpy helps a lot. ;) [CODE] #include <stdio.h> #define R 4 #define C 5 int main() { int i,j, r, c,n; int grid[R][C]={ {0,0,3,4,5}, {0,3,2,1,6}, {0,0,0,2,0}, {6,2,0,3,1}, }; int temp[R]; printf("\n\n\n"); for(r=0;r<R;r++) { for(c=0;c<C;c++) … | |
Re: This is what I've used for Shell sort: [CODE] //Shell sort void shellsort(int A[]) { int i, j, gap, temp; for(gap = MAX/2; gap > 0; gap /= 2) { for(i = gap; i < MAX; i++) { for(j = i - gap; j >= 0; j -= gap) { … | |
Re: Check out "Brainphuck" language, on Wikipedia. (with an 'f') ;) It messes with you, but it's not English, for sure. ;) They mention others, as well. | |
Re: If you had a discount array, where every day was represented by the number of the row, and every column represented the hour of the day: [CODE]Sunday (row 0): 0 (midnight) 1 (0100) 2 (0200) 3 (0300), etc. Monday (row 1): 0 1 2 3 [/CODE] Then each element could … |
The End.