949 Posted Topics
Re: For me, the above just won't do. I couldn't care less about the "annoying" aspect of the output! ***WHAT*** is the problem that has you stumped --- EXACTLY. What is your input - how many words do you need to handle. What is your output - what's wrong with it … | |
Re: The for loop restricts the number of students being assigned marks. It could restrict it to 0, or to 20000, (or more), depending on what the user input as his/her choice. | |
Re: One example: [CODE] #include <stdio.h> int main() { int i, n ; double d = 0.0; d = 3.33 * 3; n = d; printf("\n N=%d D=%lf", n, d); printf("\n\n\t\t\t press enter when ready"); i = getchar(); ++i; return 0; } [/CODE] Note how anything after the decimal point is … | |
Re: You pretty much have it: [CODE] char array[]= {"Lara","Lin","Nitin","Krishna","Sophia"}; [/CODE] If you want the names on their own row, then add another dimension to the array: char array[5][] = { {"Lara"}, {"Lin"}, etc. | |
Re: Turbo C is smart about how it handles this - it won't just move one int at a time. I use ver. 1.01 of TC, and I get an error on main() without a return int, but it will allow void main() with no return. Can you use an int … | |
Re: [CODE] j=-1; for (i=0; i<size; i++) { if (counter % row == 0) { j++; } pmatrix[i]=pmatrix[i]/ratio[j]; printf("pmatrix %d after ratio: %f \n",i,pmatrix[i]); counter++; } [/CODE] In the if(counter % row == 0) line, are you aware that when i== 0 (first time into the loop), that the statement will … | |
Re: Yes, we can help, but I see no program to help. We help - we do not *do* the homework for you. | |
Re: I can't get it to work, but I can see that it's close. This is with the C compiler in Turbo C/C++ ver. 1.01. This uses direct video writing, and oddly, direct video writing still works with Windows XP (32 bit), as the operating system. That's for certain! But I … | |
Re: [QUOTE] the hex value 00 00 00 00 00 BC 61 4E (LSB) which is stored in string as char data[8] = {0x4E, 0x61, 0xBC, 0x00, 0x00, 0x00, 0x00, 0x00}; [/QUOTE] It looks like the char bits need to be swapped, front to back. Is that right? An endian switcheroo. … | |
Re: If you don't want question marks messing up your numbers, why put them in char *foo? Your logic and English both leave me with question marks. ;) | |
Re: This is Selection sort: [CODE] for(i=0;i<n-1;i++) //OK { for(j=i-1;j>n;j++) //j=i+1 { if(a[i]<t) //if(a[i] > a[j] { t=a[i]; a[i]=a[j]; a[i]=t; } } a[i]=t; //delete this line entirely } [/CODE] j=i+i is because i<n-1, see? There's always room for j one more than i. Selection sort is a good sort to memorize, … | |
Re: I gave you [B]explicit[/B] instructions on how to get started in graphics mode, but you've ignored them, and just now you're posting up some half-baked lines of code with no logic in them, as a "clue". And they're not even from you! My first "clue" is that you won't have … | |
Re: First, always highlight your code and click on the [CODE ] icon at the top of the editor. That will put your code into a special font, etc., so it becomes easily readable. Second, inside your while loop (which looks good by the way), you need to have some variables and … | |
Re: It's dicey to overwrite data in a file - any error, even a disk error, can ruin the entire file, until the file is rebuilt. That is a time consuming process, which may not fix all the data, anyway. So what to do? Most programs do it this way: When … | |
Re: [QUOTE=jeevsmyd;1269929]use of a string did solve the telephone number problem and use of gets resolved the space issue.. but I still dont know what is wrong with the use of clrscr() .. How do I clear the screen before the other question is asked? is there any other way so … | |
Re: If you're using conio.h, you have no need for curses, and vice-versa. Decide which library you like (conio.h) <cough, cough>, and forget the other. ;) | |
Re: I wouldn't go that way with your logic. Don't use ascii numbers for your letters, unless you really need to. Use char's for letters, and stick with 'A', 'B', etc., instead - much easier to read and intuitively understand. A couple things to get figured out: 1) You need to … | |
Re: Welcome to the forum, Sumanawal. :) More details are needed. You can't put a graphics image into a console (text) window, but you can adjust the background and text colors, in a console window. Are you trying to work with a graphics window, or a console window? | |
Re: Get to know the problem - really analyze it, in this case, by doing it by hand with paper and pencil. After you get the steps down into small steps which you can readily identify, then write down those steps -- That's your pseudo code. Check your pseudo code, that … | |
Re: What is the upper range of USHORT on your system? (check limits.h, etc.) Could you be overflowing the upper limit of it, or of the CD drive? | |
Re: TIME is not a variable, TIME is being replaced by the pre-processor, by the digit 5. So the compiler never see's TIME, and knows nothing about it. You see the results of this 1) because the program is correct and 2) because the program will compile. | |
Re: This is a bit of code showing how to move the cursor, using one API, in the console window. [CODE] //you need to include <windows.h> void Gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } void function Where I want to move the … | |
Re: If you use scanf(), you have to know what scanf() does and does not do: 1) For char input, scanf() will take *ONE and one ONLY* char. That means that the newline char from hitting the enter key, is still in the keyboard buffer. Which means that the NEXT scanf() … | |
Re: I strongly suggest you take this subject up with forums or *newsgroups* that specializes in computer editing of images. You've moved away from C programming, and you need to follow that. Come back if you have a C question or problem. | |
Re: I see these problems with your program: 1) non-bomb squares adjacent to your chosen square, don't "avalanche" open. 2) you can't mark a square as a bomb, like you can in Minesweeper 3) the game doesn't end when the last free square has been chosen. It should be congratulating me … | |
Re: The same way you know when a line ends - it finds the '\n' (newline) char. fgets() will have problems if the text is long, and has no newlines in it. That's odd, but I have seen text like that before. | |
Re: Take each function, make a note of: 1) What the function does correctly and 2) What the function does not do correctly That's the first step to debugging your program, and that's what anyone who wants to help might need to do, right off. This will help save them a … | |
Re: A great deal of what you want is included in Turbo C's help files. After starting up the IDE (the editor inside Turbo C), click on "Help" on the far right hand side, and then on "Index". One graphic function that you will certainly want to look at is "rectangle" … | |
Re: Use fgets in a while loop. When fgets() returns NULL, then you have reached the end of the text file. Aha! Inside that while loop, fgets() will put each line into your char array, which must be large enough to fit all the names into for ONE line. (for even … | |
Re: You need to address these questions to the manufacturer's web site. Another idea would be to try asking on a forum for CD software, like ImgBurn. You may need to ask several times before you get an answer, so don't be afraid to shop around. It's impossible to know how … | |
Re: I would change "relation" to "verb" and use fgets() to put each line of the file, into a char buffer[] array. Then take all the char's from the first up to the first question mark, and copy that into your subject member. Then take everything from that point, until the … | |
Re: If it's a binary number (don't let the hexadecimal value mislead you, i is still just a binary number, internally), and you moved the one's in that binary number, two columns to the left (filling up behind it with zero's). What would you have? We know that 0xff is 16 … | |
Re: No, they're different languages, but Objective C can run C code, since it is a superset of C. Read all about it, on Wikipedia: [url]http://en.wikipedia.org/wiki/Objective-C[/url] | |
Re: You should have a doubt, because if your compiler will run the code, it will give you a NULL pointer assignment error, right at the end. At least, that's what I got. This kind of "fun and games with freakish C syntax ", is a total waste of time, and … | |
Re: ADHR should be, by convention, a defined global variable or constant, (thus the all caps). First that value (defines in C are a straight substitution) is left shifted two places, then the result is cast as an integer. Finally that value is returned from the function. | |
Re: Malloc() is part of stdlib.h, which you did not include. You would have received an error, except you cast the return from malloc(), so it didn't give you one. In addition to the above advice, you need to include stdlib.h in your header list, and in C, there is little … | |
Re: You need to look at your hardware for such small timing intervals, not software. Are you using a 555 timer IC chip? What timer features does your PIC chip offer? That's where you need to look - C that uses your hardware, rather than your OS. | |
Re: A nice way to do this is to put each line of text, into a char buffer[] array, say about 10 char's larger than any line in the text. (roughly). Then you can use the simpler index of the buffer[] array, to move around as you'd like, and string to … | |
Re: You can use strstr() to find a sub-string (word), within a string. In your case though, you just need to find line[0] == 'F', and that's your line. :) I would go as far as testing it a bit further, though: [CODE]if((line[0]=='F') && (line[1]=='r') && (line[2]=='o') && line[3]=='m') { //rest … | |
Re: Would you post up a small sample of the input file, which is giving you this problem. I'm having trouble visualizing what the problem could be. | |
Re: Please post up a little snippet of code trying to do what you want, and let's see what the problem is. | |
Re: It may not be guaranteed to be portable by the C standard, but I've never heard of a C compiler that doesn't have signed and unsigned char's. I'm sure there's some minimalist one that is that way, but it's designed for embedded applications, I'd bet $$$. | |
Re: You don't want to over-write records and shuffle them around a lot - that's risky business, and unnecessary. Instead, just mark the name or a record number (like an id number with students), as zero or '\0'. Now, your program can tell that record has been deleted, and is available … | |
| |
Re: Are you trying to dynamically size the array with malloc or calloc? "something happened here" is a complete mystery to me. | |
Re: Second for Walt's recommendation - very clean and easy as well. | |
Re: I agree, this is not up to snippet level, overall. | |
Re: If you have Windows XP 32 bit, you will be able to run the Turbo C programs and IDE, on it. If you have the 64 bit version of Windows XP, then I don't believe you can run Turbo C, because it's 16 bit software. You could perhaps use something … | |
Re: you're using i as the iterator for both of the nested for loops! ;) And why are using two loop for this? You only have 2 elements in your array to fill up. Can't you get rid of the inner for loop? |
The End.