949 Posted Topics
Re: ddd ccc eee is not in sorted order, so I'm not sure if you want to sort in ascending or descending order. You should keep the 2D array, no need to change that. you can't use temp like you have it in the sort portion. When you assign it to … | |
Re: No casting or typecasting is needed for malloc(). It returns a void pointer which the program will automatically change to the right type, for you. Very rarely, you'll need to do a cast of the pointer, manually. You need to include stdlib.h for malloc to work. If you need more … | |
Re: I don't know a single one, it's a diminishing language for studying. Google does have lots of hits, however. Several tutorials included. | |
Re: You can't delete an element from an array - they are fixed. Why don't you post a simple example of what you want to do. Your description is dodgy, (or maybe it's just too early?). ;) | |
Re: Are you trying to USE atoi() in your program, or are you trying to make your own atoi() function? The C atoi() function will need a pointer to the char array, not this: atoi({abcdefghij}); I have no idea what the abcd... stuff is all about. | |
Re: Sure! Why not? Here's the thing -- you have to contribute idea's and sometimes, code into this. I'm not going to just post up a program for you, and I hope you don't want to be a "code leech". So, what does your instructor say to use for an algorithm … | |
Re: rand() can give you a specific range of random numbers. Just set it up for 1 to 5, four times. 1 2 3 5 Inside a loop, you can put the "number" together, from those digits if you want: 5 * 10^0 + 3 * 10^1 + 2 * 10^2 … | |
Re: This link has Turbo C/C++ 1.01, which I strongly recommend, because: 1) It's a newer product, and has fewer bugs than the older Turbo C 2.0 2) It has both a C++ and a C compiler - files with a dot c filename will be compiled with the C compiler, … | |
![]() | Re: Here's one big error: [CODE] scanf("%s",inpt_str1); for(i=0;inpt_str1[i]!='\n';i++) { len1+=1; concat_str[i]=inpt_str1[i]; } [/CODE] scanf() does NOT include the newline char, into the string - that's fgets(). scanf() (infamously!) leaves the newline behind. So there is no stopping your loop. Change the '\n' to '\0' (the end of string marker) (which scanf() … ![]() |
Re: You need to ask questions about your program, rather than posting your assignment and saying "thanks" for the solution. It is your assignment, after all. You won't learn by not working with it. And Welcome to the Forum, Ahmed! ;) | |
Re: You only need to include struct members for fields that you need. For students: idNum, fname, lname, gradYr, course, and DOB (DOB=date of birth). You don't list it, but it's quite standard. Course would be their major field of study perhaps. Sounds like all you'll need, from your description. Before … | |
Re: Just a quick note: 1) On programming forums, you NEED to use CODE tags. In the editing window, highlight your code, and click on the [CODE] icon. Otherwise, your code is difficult to study, and will be generally ignored. 2) You don't have any #include files listed in your program. … | |
Re: You need to use ARRAYS of structs, of course - if you have multiple cars to track. ;) | |
Re: I'm not familiar with emulators, but suggest: 1) Use #defines for the memory addresses, to clarify things with them 2) Tell us exactly, *what* is it that has you stumped "Needing help" doesn't bring a focus to anything specific enough to tackle. I doubt VERY MUCH if anyone is going … | |
Re: I'm hesitant to say I can answer your questions - but I've done a lot of programming in Quickbasic Pro. Post up what you have done, and what specifically you need help with. That's the only way that anyone could help you. | |
Re: You might want to read up on base 2 (binary), base 16 (hexadecimal), and compare how they work, with what you know about base 10 (our normal number base). What specifically is it that you need help with? Can you post code to show what you're trying to do? And … | |
Re: A text file will be given certain translations (like a newline char gets changed into a CR/LF combination of two chars). Open the files in binary mode: "rb" and "wb", for sure. Then you *may* need to change char c to an unsigned char. And on the forum, highlight your … | |
Re: If you're taking a class, use the compiler that the teacher will be testing you and your programs, with. There are two highly rated free C compilers that I know of. One is Microsoft's Visual Express (Google for a d/l site). The video is helpful to d/l as well. The … | |
Re: Exactly right. Structs are used in C, to combine related variables, into one object. | |
Re: I don't like your algorithm, nor do I see anything "divide and conquer", about it. Try this: 1) take in all the numbers of the array, then 2) use Quicksort to sort the array Quicksort is a *brilliant* example of a divide and conquer algorithm. | |
Re: To have your code look like code (and be easily read), highlight your code, and click on the [CODE] icon in the editing window. You need the code tag without the backslash char: '/', before the program starts, and the code tag WITH the backslash char, placed after the program … | |
Re: First idea, is to use a keyboard and editor, ;) but seriously, read up on permutations and programming in general. This is not a trivial "Hello World" kind of program. Second idea, is to consider that hacking into someone's computer is a crime in most jurisdictions, and that your time … | |
Re: click on the "Snippets" tab, and study the Binary Search snippet. Your logic is *way* off the mark. | |
Re: You don't need us to try and fill in a books worth of info, on image compression. Use Google and be prepared for a lot of reading. There are dozens of image compression formats already developed. Why do you need a new one? It's not like these formats are worn … | |
Re: Unless the input is *strictly* formatted, don't use scanf(). You want a char buff[90] (nice and big) to hold a full line of input from the user or file, *PLUS* one newline: '\n' char and one end of string marker char: '\0'. The format for it is: [CODE] char buff[90]={'\0'}; … | |
Re: I would use logic like this: [This is not "code", it's pseudo code, in C format. Difficult to describe it accurately, without code like syntax, imo.] [CODE] /* you can count these yourself, without using strlen(), if necessary */ lensub = strlen(substring); lenstr = strlen(string); for(i=0;i<(lenstr - lensub);i++) { j=0; … | |
Re: I'm confused. Linked lists can be done as a queue (a regular list or line), or as a stack (like a stack of plates). push and pop are used for stacks, and data is entered one at a time, at the top of the stack, only. lists use a FIFO … | |
Re: I have bind.exe, as part of Visual Studio C/C++ 6.0. It is in the C:\Program Files\Microsoft Visual Studio\Common\Tools directory. I looked at it with a hex editor, and neither I nor my AV program (scanned it twice), see any indications that it's a virus**. It says it binds an image … | |
Re: fire up the IDE, and click on "Options" then "Directories". Check the listing for your header files. When you include the header file, be sure to add the < or " char's around the file name: #include <stdlib.h>. Works for default directory locations. "stdlib.h" works for limited searching for the … | |
Re: We just had a wonderful example of a binary search program in "Snippets" section of this forum, about two weeks ago. | |
Re: The program uses nr_products and nr_prices, without having given them values! :( These variables were declared BUT NOT initialized to any value. if statements need TWO == in them, instead of just one =. You need a for loop (best) to control how many times a price needs to be … | |
Re: Most compiler's have a default return type of int - like Borland used to. Today, you should be explicit about your return types, and they should be included in your function prototype. What is the return good for? Any answer to a computation the function is doing! Serious programming doesn't … | |
Re: The answer is that scanf() leaves the newline char (which is generated when you hit the enter key), behind. To solve your problem, add a getchar() line of code, immediately below your scanf(), and all will be well, (unless you press other unnecessary keys). Now you know just a bit … | |
Re: After each scanf(), add a getchar() to pull the left-behind newline char, off the keyboard buffer. Scanf() is fragile - it requires a clean input stream, and even then, it should be used for highly formatted input, only. fgets() is far more robust and flexible. Please use [CODE] tags around … | |
Re: Welcome to the forum, Pdoratis! ;) The thing is, you NEED some experience with C, to work on a C program - that's the simple fact. We won't just do your assignment for you - especially important is for YOU to put some effort into the start of the job. … | |
Re: You need to highlight your code, then click on the [CODE] icon in the edit, which will post up two code tags for you. Paste your code, between those code tags. Otherwise, you code will be turned into html text and look really bad. And yes, as noted above, you … | |
Re: Time is usually measured in C with two clock_t variables: [CODE] #include <time.h> #include <stdio.h> #include <dos.h> int main(void) { clock_t start, end; start = clock(); delay(200); //adjust as needed for your compiler and OS //sleep(200); //ditto end = clock(); printf("The time was: %f\n", (end - start) / CLK_TCK); return … | |
Re: Int return codes help answer the important question: I ran the program, but did it finish normally, throw an error, or get caught in an endless loop of some sort? By custom, a zero return indicates a successful program run. Other numbers might correspond to specific errors, and no return … | |
Re: Vijay, you need to stop posting in an old thread - your post will be pretty much ignored and considered old as well. Or posters will answer Psionics questions, and not yours. :( Start a new thread, and be as specific as you can. Post the code that you're working … | |
Re: What have you tried to solve this problem? | |
Re: IMO, the best thing to do is Google one of the many C# tutorials on the web, and go through them first. THEN you'll be primed to start working through whatever problem you want to tackle. When you have NO idea of where to start - don't start - get … | |
Re: We would need two things to help you: 1) See your work starting this program and 2) Post the details of the program you need to make. "Receipt program" isn't nearly enough to know what you need the program to do. And Welcome to the Forum! ;) | |
Re: I never give people the address to my house. I always give them a *copy* of the address to my house. They always find my house, with no problem. ;) When you post code, use CODE tags around your code - always. | |
Re: Lots of problems with this code: 1) The logic is poor - an endless loop, then a break here, a break there, another break someplace else... Is this logic for a program, or a Chinese fire drill? ;) One break, maybe two, OK. Three? No. This is WAY too simple … | |
Re: In most cases, you don't want to shuffle data records around in a database. If you have 3,000 students in a school, and a 3,200 student array of structs to handle their records, whenever a student leaves the school, you don't shuffle a bunch of records down to compact the … | |
Re: Two things: 1) Your logic for max is reversed. Use > max, not < max. [CODE] min=adc_result[0]; max=adc_result[0]; for(j=0;j<i;j++) { if(adc_result[j]<min) { min=adc_result[j]; } } for(k=0;k<i;k++) { if(adc_result[k]<max) //change the < to > { max=adc_result[k]; } } [/CODE] and 2) You only need one for loop for this, you can … | |
Re: Your for loop has a bad test to end the loop. x will always be greater or equal to zero, so the loop quickly is working outside the array. [CODE]for(x=0;x<strlen(title);x++)[/CODE] should work. It is more efficient to first, before the for loop, get the length of the string assigned to … | |
Re: In the second program, you have this bit of code: [CODE] char *a,*b; FILE *fp,*fp1; fp=fopen("int.txt","r"); fp1=fopen("obj.txt","w"); getsym_op(); while(1) { fscanf(fp,"%s",a); [/CODE] Looks to me like you're assigning a string to a, but a is a pointer (not an array as you've used before with the same name), and a … | |
Re: Use an if() with else if() series of statements. When Narue speaks, wise coder's listen. Get those ears cleaned out, dude. ;) | |
Re: Defines are just stupid "find and replace" substitutions, made before the program starts, and that can lead to a LOT of problems that are hard to de-bug. A small function seems perfect for this. |
The End.