949 Posted Topics
Re: Oscillator, *now* tell us how you [B][COLOR="Red"]really feel[/COLOR][/B] about this thread, won't you? ;) ;) | |
Re: The getchar()'s are there to pull newlines off the keyboard buffer. In this case, since the program is scanf()'ing for numbers, the getchar()'s are not needed. Scanf() will jump over a newline, if it is looking for a number. Money should not be an integer, when the user enters it. … | |
Re: Aurorian, here's an important idea to remember about floats and doubles: they can't perfectly represent every number. Integers can represent every (whole) number, but non-integer data types can't. They'll be *very* close, but not quite perfect. So making comparisons of float1 == float2 type, are a bad idea, overall. You … | |
Re: This is a lot of information that although old, is still used by Windows (up to XP that I'm sure of). Also, there is a short example program, using findfirst and findnext. /* This is from Turbo C/C++ (the C compiler), ver. 1.01 Help findfirst: Searches a disk directory. findnext: … | |
Re: Change the return from your compare function to: [CODE] return(*(int*)a->id - *(int*)b->id); [/CODE] And it works fine. Nice program, btw. That GD casting on the return from the compare function, is one reason I dislike C's qsort. Sure, it's nice for different kinds of data, but damn it, people sort … | |
Re: You need to assign the address that fopen() returns to your FILE * (pointer). [CODE]FILE *fp; fp = fopen("Keywords.txt", "rt"); if(fp == NULL) { printf("\nError opening file\n"); return 0; }[/CODE] | |
Re: Welcome to the forum, Shubh. :) A few important suggestions for you: 1) For your problem, start a new thread. Using someone else's is called "thread hijacking", and will get people upset with you. More people will see your thread when you start a new one, and respond. 2) When … | |
Re: What we require, is that you take a stab at doing this assignment, and post up your code. Tell us where you're stuck. We can help, and the fact that it's Turbo C will not be a problem. I use an early version of it, myself. (The C side of … | |
Re: Your fscanf() line of code doesn't have a format specifier: [code] while ((fscanf(fp, " %s[^\n]", line) != EOF)) [/code] | |
Re: The newptr should be sized for a pointer, so add an asterisk to this line: [code] newPtr = (struct Stack *) malloc(sizeof (struct Stack)); and make it: newPtr = (struct Stack *) malloc(sizeof (struct Stack*)); //don't you want to connect the rows, with it's columns? for(i = 0; i < … | |
Re: Please post up your most recent code. I know you've made some changes, and I'm late joining this thread. | |
Re: [QUOTE=xavier666;1143873]Only for merge sort. The rest of the algorithms do not need a temporary array. By the way, Happy Holi![/QUOTE] Radix sort will require an auxiliary array, as well. What I've done for my AllSorts program, is have the second array made equal to the size of the original array. … | |
Re: When you are fscanf()'ing a char array, you need to just have the name of the array - that IS a const pointer to the base of the array. You need to remove the '&' in front of the char arrays that you will be scanning: [CODE] while (!feof(fp)){ fscanf(fp,"%d\n … | |
Re: I doubt very much if he has a lot of choices right now (after the school year has started), in what compiler the class is using, or what college to attend based on the compiler being used. Turbo C is no problem, but it sounds like you need to use … | |
Re: Is this what you're looking to do? [code=C] colMin = array[0][0]; colMax = array[0][0]; for (col = 0; col < MaxCol; col++) { for(row = 0; row < MaxRow; row++) { if(colMin) > array[row][col] colMin = array[row][col]; //and repeat above if statement for colMax } } [/code] | |
Re: [QUOTE=the reaper;662576]i am sorry guys..i really don't know maybe because i have about 1 months of experiance in "c"...i will be on the lookout for all of your help...(I gotta admit it you are better then me when it comes to programming)..[/QUOTE] Then I would *hope* that we are better … | |
Re: Your url takes us to Free Image Hosting, but not to your picture/image. :( You have a large sorted list, and a binary search would be excellent. You'll need a few little tweaks to it: 1) If the person types a 'b', you change that to 'b ', (b + … | |
Re: Basic error in your logic. You can't say for sure that the game is not over NOW, (after the opponent or yourself, has made a move), unless you check, first. I use a function named IsWin(), but the name is not important. You must include logic to check if the … | |
Re: [QUOTE=acchao;655634]Let's see if I can try to explain myself better with this small test code: [code=C] #include <stdio.h> #include <stdlib.h> #include <math.h> int main(void) { int test_num = 216; int test_num2; char test_string[10]; FILE *fp_asciiHeim, *fp_converted; //create a read/write dummy file if((fp_converted = fopen( "data01.txt", "w+" ))==NULL) { printf("cannot open … | |
Re: I'm not familiar with C++, but a few points on prime numbers: If no divisor is found w/o remainder less than or equal to the value of the square root of the number, then the number is prime. This really speeds up your testing. Numbers which divide evenly by 2,3,5, … | |
Re: I want to heartily second Vernon's post - not only is it a great trick for your problem, but it can be used for many others, as well. It's usually called Distributed Counting or Bucketsort, but you don't hear much about it, for some unknown reason. It has several advantages: … | |
| |
Re: No, I'm not going to try and run your code to find out what the problem(s) may be. I'm going to wait for you to tell me what *specific* problem(s) you have found with the program. [COLOR="Red"][B]It is your program, after all, not mine.[/B][/COLOR] Is the input wrong? What's wrong … | |
Re: Is this right? (Line 75 or so) [code=C] if (element > element [left+1]) //??? { temp = element[left+1]; element[left+1] = element; //??? element = temp; //??? } [/code] element is the *address* of the array, a pointer to the array, and it's being compared with a value of the array?? … | |
Re: [QUOTE=hoticejin21;650600]guyz im having hard time of making a program that could run like a simple ATM machine using turbo c(using conditional statement and looping)... I can't think will coz the dealine of submission is on next week... could you gave an idea of that program.. pls??? i will just change … | |
Re: I believe there are 2 sub cases when the user presses Enter: 1) If the cursor position is above (less than) the bottom row of the current screen (usually 25, but may be 43 or 50), then the cursor just moves to the next row down, and to the first … | |
Re: [QUOTE=flecture;641986]hi cld anybody explain me the concepts of continue,break,return statement with an example using c program[/QUOTE] Sure. Then we could write your text book, your website tutorial, take your tests, etc. I don't mean to be harsh, but we're not Google, we're not auditioning to be your tutor, and we're … | |
Re: This line of code is correct: [code=C] index_s1 = strlen(num_s1) - 1; [/code] Without the " - 1" in there, you are going outside the bounds of the array. Arrays are zero based, so if the array has 12 elements, and you access array[12], of a char array, you will … | |
Re: Just system("sample"); in a loop, will do. You may need to add a sleep(# of seconds) statement, before the next loop, so your bat file will have time to run, before the next call to run it. Do you know if the commands inside the sample.bat file will actually send … | |
Re: Line 571 has this code: [code=C] printf("Edit this record?(Y/N)"); scanf("%s", answer); if(strcmp(answer, "Y")==0) [/code] Which I believe should be changed to: [code=C] scanf("%c", &answer); //answer is a char, not a string if(answer == 'Y') //note the change to a single quote for a char, instead of double quotes etc. [/code] … | |
Re: First, I would change the variable "int o;" to some other name. Never use "o" or "O" for variable names, because they look too much like 0. Second, in your description of the problem, you are moving in the wrong direction. You start with the *smallest* column's number, and work … | |
Re: I'll agree with you that you need help - anyone who names their array "element[]", is utterly at their limit! :) I don't agree with your algorithm, however. It looks like it will fail when you are sorting more numbers which are not favorably arranged already, but I haven't run … | |
Re: You didn't post the program - you posted "something like it". So it's not just a snippet of code which shows the problem, and it's also not the whole program. I'm not going to waste time with it. Your quote: [quote] [COLOR="Red"](if there is any undeclare variable just ignore.. it's … | |
Re: [QUOTE=jirving;640972]i need help on my homework problem. i have done the operations part (+, -, *, /, sqrt) but i am really having a [B]problem on making my calculator accurate up to 40 digits and to truncate all the non-significant zeroes on the output[/B]. i don't know what data type … | |
Re: [QUOTE=patel_anks;640180]Hi can anyone help me, I am learning the language C but need some help writting some code. what i need to do is from the input of the keyboard i need to find the max and min of some values and out put them. what i got so far … | |
Re: Shouldn't your program have an int main() function, too? :) | |
Re: [QUOTE=sivakrishna;633221]plz provide the c program to remove the blank spaces[/QUOTE] No. That's not what we do. The way it works is *you* post your code, and also post up a description of your problem or error with that code. We will take a look at it and suggest ways of … | |
Re: [QUOTE=neknek;633619]I have problems with searching & sorting strings in a file... I want to alphabetize the string so I did this [CODE]{for(x=0; x<100; x++) { for(c=x; c<15; c++) fscanf(stdin, "%s", student[c]->surname); if(strcmp(student[c]->surname,student[c+1]->surname)<0) {strcpy(temp,student[c]->surname); strcpy(student[c]->surname,student[c+1]->surname); strcpy(student[c+1]->surname,temp); strcpy(temp,student[c]->name); strcpy(student[c]->name,student[c+1]->name); strcpy(student[c+1]->name,temp); strcpy(temp,student[c]->number); strcpy(student[c]->number,student[c+1]->number); strcpy(student[c+1]->number,temp);} } }[/CODE] when i run the program, it just … | |
Re: As I understand it, Binary search will always be faster if access times are constant (as in an array in RAM or cache), and Fibonacci search will be faster when the distance and access times, are proportional. Like on a hard drive or tape drive, where if the next item … | |
Re: [QUOTE=inventer;634421]Hi! I am new to C programming, so this question might sound foolish. I have a problem with output of a program (sometimes the output is wrong) Following is the program: (I am using Turbo C compiler) /* Calculate simple interest */ #include <stdio.h> main() { int p, n; float … | |
Re: Imagine you're in a large house, with several rooms. Each room is a function: *you can only carry in *copies* of what you want, into each room, unless it's already been put there (ie, it's global in scope). *you can only walk out of a room, carrying *one* item *if … | |
Re: Looks like the variable "num" is not returned to main, the variable "n" is never passed the value of num. That leaves your sorting function with 0 strings that are being asked to sort. Return num and assign it to n, and see if that doesn't help. | |
Re: Recalculating the time in every recursive call, get's quite expensive. Perhaps depth mod 8 == 0 would be enough? Also, you re-draw the board for every move. You only need to redraw two squares after any move - the from square, and the to square. It also gets rid of … | |
Re: [QUOTE=J-son;626074]Can anybody help me to solve this problem? My program doesn't work as what it is required. Here is the question and my program code. Thanks. [CODE=c] /**Twenty-five numbers are entered from the keyboard into an array. Write a program to find out how many of them are positive, how … | |
Re: I don't have Turbo C 2.0, but this runs fine in Turbo C/C++ ver. 1.01, as a C program. Note int main and the include header. IIRC Turbo C 2.0 came before Turbo C/C++, but it's been a long time. [code] #include <stdio.h> void f(char *); char h[] = "hello"; … | |
Re: Did you try my idea I posted on Cprogramming? Post up some code! Even if it's wrong, post up some effort you've made, and show us just what you want. There must be 100 different ways to make a status bar. | |
Re: May I suggest you use the digits 1, 2 & 3, instead of 0, 1, & 2? Because you can't "make" a number which begins with 0's: 01, 001, 02, 002, etc., are not a number. Anything beginning with a real number, would be fine though: 101, 20, 103, etc. … | |
Re: Gaurau - Welcome to the forum! ;) This thread has been "dead" for several years, however. Please start a new one with your topic, and let these old threads, rest in peace. Maybe use the Google translator service? I can't figure out what you're saying. |
The End.