- Strength to Increase Rep
- +14
- Strength to Decrease Rep
- -3
- Upvotes Received
- 206
- Posts with Upvotes
- 176
- Upvoting Members
- 109
- Downvotes Received
- 36
- Posts with Downvotes
- 33
- Downvoting Members
- 23
949 Posted Topics
Re: You're looking at the same problem, from WAY different perspectives. Narue has a lot of experience, at a high level, with languages, while VEGETA-DTX has very little experience, but STILL has a valid point to make. As the old quip says: (and I roughly paraphrase) "The great achievements of man … | |
Re: Line 17 puts the needed end of string marker char, into place. Remember, chars are just a bunch of chars, UNTIL they have an end of string marker in place, after them. bunch of chars: just a bunch of chars. now a string: just one string.'\0' It's confusing, because the … | |
Re: The path to the BGI drivers. | |
![]() | Re: You've got a pointer to a pointer - and you've set aside no memory for it, at all. The algorithm may be OK, but it's not one I'd recommend you use. Strive for clarity and simplicity in your code. adding two matrices into a third matrix which is NOT a … |
Re: First, be aware that your code is C++, and you are compiling it (obviously) with a C++ compiler, instead of the C compiler. This answer works in C, but you may need to adapt it to work with C++. Sachi's code is also C, since this is the C forum. … | |
Re: A "void" is an empty area - like "space is mostly a huge void". It also means "amounting to nothing" as in "the lawsuit was made null and void". So a void function is any function that returns nothing. It may say "return" at the end of it, but it … | |
Re: Very interesting Brian, thanks for sharing! ;) And welcome to the forum. :) | |
Re: Turbo C has it's quirks, but here's some hints I use (and I use Turbo C/C++ (the C compiler portion), very often. 1) Use Turbo C/C++, NOT "Turbo C". Turbo C was an earlier product, and is buggy. Turbo C/C++ is fine - I recommend ver. 2.0, but 1.01 is … | |
Re: [QUOTE=keval_hack;1638142][I]Interesting tricky program using C & C++: [/I] [B]Program 1:[/B] Create a Program which produce output "Hello World" , the program must not contains semicolon ; in other word any statement of the program will not have a termination semicolon. [B]Program 2:[/B] Write a C or C++ program which run … | |
Re: sureshshan1292, in the spiral problem, you should be hearing warning sirens that your algorithm is too (low-level in the logic, explicit, or specific), and not abstracted enough. That is a LOT of code! Are you still interested in this problem, or did you figure out what you wanted, already? | |
Re: It's good. ;) The one I like moves the stream pointer for the keyboard - very elegant, but everybody asks WTF is THAT? | |
Re: Perhaps you are using the angle of 45 you have defined, instead of calculating the real angle on the bounce off the bricks, or the wall. If you Google for that equation, you'll find it easily. I don't have it on this system, but it's simple geometry. | |
Re: The bubble sort doesn't "bubble". ;) Bubble sort compares only adjacent values in an array. What you have labeled Bubble sort, is actually Substitution sort, which is in the same class, but compares non-adjacent array values, 95% of the time (or so). Also, Bubble sort usually has (and always should … | |
Re: You need the program to find up to 1 million prime numbers, in 5 seconds? That's a job for ya! ;) I just tried out my trusty prime number finder, and it took it 5.8 seconds with a pretty fast i7 cpu system (3.5GHz). To go from 10 seconds to … | |
Re: I believe you can run Turbo C in Windows 7, but it has to run inside a virtual machine. This is how it ran in WindowsXP as well, using the NT VDM. I haven't done this yet, but surely will some time soon. Google it, and also check out DOS … | |
Re: Welcome to the forum, Akshay1. This thread is 3 years old - how about starting a new one? More specifics of your assignment, would help. Also, what is stopping you from including string.h and using strstr() to find your string in the text file.? | |
Re: I applaud your energy, but you don't understand what programming is all about. The rare goto is OK, but there's no need for them in TTT. C (and all programming languages to some extent), are meant to be a concise and efficient way to do something. Where accuracy is paramount, … | |
![]() | Re: If you're having problems with a do loop, you need to post up code that includes the do loop. ;) Using CODE TAGS! <of course> Putting your code right between code tags, lets your code stay looking like code, and not like a dog's breakfast. |
Re: You're all off the mark. The answer is "Whatever you want the difference to be." ;) | |
Re: Hi Nakul, Try to learn C the right way: 1) It's always int main(), never just main() or void main(), and it always has a return integer (generally always 0). 2) now let's make your program look like a *program* on the forum: Just click on the [.code] icon, in … | |
Re: One concern I have with your code is that x doesn't appear to be reset, so the while loops working with it, are going to go bust. I don't believe you understood the wisdom of deceptikon's post, right above yours. Your code looks positively PAINFUL. You don't need to work … | |
Re: If you know that all global variables, with no storage class mentioned, are 1) kept until the end of the program. and 2) available to your program in any function, without using a parameter. and 3) may be overshadowed or covered, by a local variable with the same name, in … | |
Re: size_t j = pon - string1[0]; is the index to the first char of string2, within string1. | |
Re: I like #1 or #3. #1 because it uses bit shifting, which is always fast. The only minus is the subtraction. I like #3 because it allows full optimization by the compiler - which surely is set up for something as common as multiplication, in unbeatable time. The #2 I … | |
Re: You need to add curly braces { } whenever you have an expression with multiple lines of sub expressions, or it won't work as you want it to. if(some test is true { first code expression; second code expression; } Without the braces being in the above, ONLY the first … | |
Re: If you want your calculations to be accurate at all, you need to use doubles or floats. Integer division is especially (spectacularly) diabolical. And "millage"? Really? | |
Re: I really like Pelles C for Windows. It's NOT C++, but it has an extensive help section, full IDE editor, debugger, profiler, and it's own forum for learning the in's and out's of using it. There is a learning curve for using it, because it is a Windows program. I … | |
Re: Use the PDCurses library for all the console control you could ever want. | |
Re: Syria has a great need for humanitarian help - US and it's Allies can assist there, (and is) in Jordan. The civil war in Syria will have to be sorted out by the Syrians (plus any other fighters from Islamic countries that will participate). It will be a huge war, … | |
Re: You need to remove the newline char that fgets() always adds to the end of the string it receives. Nice actually looks like this, when it's the last word in the string: "nice\n\0". And what you are searching for is "nice\0". So a bit of code for inside the for … | |
Re: Line 53, remove the semi-colon from the end of that line. Remove lines 61 and 62. Line 94, put a space before the % in the scanf-- scanf(" %c", &entered_char); Line 96, you need to surround both logical arguments in your if statement, with parentheseis: if((argument1) || (argument2)) Line 102, … | |
Re: No there isn't. There is one to search for a string within a larger string, however. The general logic would be: #include <string.h> use strstr() to locate the word you want to replace. Save the position (pointer) it returns when it finds it. From the start of the string, to … | |
Re: Usually, I know before hand what the input will be - integer, string, double, etc. If I don't know what will be next, I take the data in as a string, using fgets(), into a char array[80]. From there it can be checked with various tests, char by char, to … | |
Re: The rand() function will repeat the very same numbers, in every run, unless you seed the random number generator ONE TIME, before you use it. So #include <time.h> #include <stdlib.h> //then srand(time(0)); //before any call to rand(), and you'll be all set. When you get a chance, you'll be miles … | |
Re: Set your system (like the rest of the world), to use UTC (aka GMT or Zulu time). Why? Because UTC is not affected by Daylight Savings Time changes. It doesn't change for it. [quote] The switch to daylight saving time does not affect UTC. It refers to time on the … | |
Re: Macros are pure substitution, and are handled by the pre-processor, before anything is compiled. Macros will be handled just as if you had entered the substituted code, without the macro. There is no run-time gain. They are a tool that can help if you sensibly, or hurt if over-used. | |
Re: Post a few lines of the csv (comma separated values): http://en.wikipedia.org/wiki/Comma-separated_values that you are having trouble with the input, and your code. It's best to get into the specifics, and see the actual data and code, rather than work from generalities of either data or code. | |
Re: You've started coding, before you finished thinking about how it should be done. The array name should be arr[], not array[], correct? Think of the logic: make an array prod[] equal in size to arr[]. Do you know how to use malloc()? Then for(each value in arr[] except the current … | |
Re: OK, but nothing was swapped. A swap of values doesn't mean simply reordering the variables in the print statement. | |
Re: If you sat down at the desk or table, and was given this string, could YOU find the date digits, inside the string? How would you do it? You'd probably start at one end of the string, and look through the string, for the first digit. When you found the … | |
Re: Not quite right though, sepp2k. 5.2 is an absolute value - it is NOT the same as the double a which was assigned the value of 5.2 AS A DOUBLE. 5.2000000 != 5.2000001 in your example. Try this: double a,b; a=5.2; b=5.2; if(a==b) printf("equal\n"); else if(a<b) printf("a is less than … | |
Re: The name of the header is <stdio.h>, not "studio.h", but your program shows it correctly. So, click on "options" and then on "directories", and check that your stdio.h file is listed as being in the directory that Turbo C++, expects to find it. It won't go looking all around for … | |
Re: Printers have a language that you can control them with. Unfortunately, they don't all use the same langauge! Unless the printer you want to control is speaking your language, you won't be able to make it do what you want. Maybe start by reading up on PCL (Printer Control Language): … | |
Re: The prime has to be less than 1,000,000, but adding up the sum must be redone for every prime - but the program doesn't reset sum to zero, when it starts working on a new prime number. | |
Re: Just strcpy() the string, into your array that you have passed into permute, as a parameter. Note that the *b[100] array is local, and won't exist after the program exits that function. Use your own array, instead. | |
Re: Welcome to the forum! We are strongly encouraged to start a NEW thread, instead of adding onto a thread that is more than 6 months old. So I'd stop posting in this thread, and re-post your code and questions, in a brand new thread. That way you get the attention … | |
Demonstrates the Right Hand Rule maze solving algorithm, with some sweet console colors and text display and erasing, in Windows. Note that if the Start is moved away from all the walls in the maze, the right hand rule fails, circling endlessly. Also, a similar failure happens if the Start … | |
Re: No. That means your programs will start in main() (at least appear to start to us), in C. In fact, C programs may not start in C, (Pelles C doesn't), but in thinking about where the program starts in C, "it starts in main() in C". Usually, it's best to … | |
Re: Not &test with fscanf, just test. char arrays don't require an ampersand, like numeric variables do If you have other problems, specify what they are. Note that gets(), while it's very convenient, is totally unsafe from buffer overflow, and has been removed from the accepted C standard. | |
Re: To optimize a program: 1) remember your first priority is always an accurate program. A wrong answer might be infinitely fast, but it's still wrong, and probably useless. Get and keep your program accurate. 2) the largest optimizing you can do, (by far), is with the choice of the algorithm … |
The End.