1,265 Posted Topics
Re: the reason is because your different functions individually parse each character without regard to what the other is doing. Specifically, your "SkipOverRestOfCommand" function disposes of the ';' character without properly accounting for it to the "SkipBlanks" function. in the even someone enters a ';' before any commands, your "SkipBlanks" function … | |
Re: you're trying to use a 20-year-old compiler on a modern OS. that's the problem. Turbo C sucks enough already, but is known to be especially more problematic when installed on Windows Vista. there are some workarounds but I'm not going to advocate them. [URL="http://www.codeblocks.org/"]The real solution[/URL] starts when you uninstall … | |
Re: this so totally does [B]not[/B] belong as a code snippet. code snippets are supposed to be working code, that solves a particular problem, and that isl also be likely to be useful to at least a few other people in the world, somewhere. but this ... this is a cry … | |
Re: this is the reason why globals are generally considered bad programming. unless you have a compelling reason to do so, do not use global variables. pass your array as a pointer argument into the functions that will be making use of it and/or modifying it. your problems will disappear. | |
Re: scanf is often the source of input problems. as you can see, you have the most trivial example and it's [I]already[/I] being problematic. since there are better alternatives readily available, you'll do well to learn to stop using it as soon as possible. i too am partial to [URL="http://www.cplusplus.com/reference/clibrary/cstdio/fgets/"]fgets()[/URL]. it's … | |
Re: header files are good programming practice especially for large projects with mulitple files. but, no, you can't just plop a header file into some other program and have it work without code available. you do need to have the source code -- in one form or another -- included as … | |
Re: Do you need to learn how to program in C? there are plenty of tutorials. Here's one: [URL="http://www.cprogramming.com/tutorial.html#ctutorial"]Basics of C Programming[/URL] Do you want to write [I]better [/I]C? there are plenty of guides. Here's one: [URL="http://www.ibm.com/developerworks/linux/library/l-clear-code"]Six ways to write more comprehensible code[/URL] . | |
Re: (1) use [URL="http://www.cplusplus.com/reference/clibrary/cstdio/fopen/"]fopen()[/URL] to [B]read [/B]all items from the file into a structure in memory, then [URL="http://www.cplusplus.com/reference/clibrary/cstdio/fclose/"]fclose()[/URL] the file immediately (2) do whatever manipulations you want on the memory structure. (3) when the user is ready to commit a change (either singly or in a batch) reopen the file using … | |
Re: i've never heard of Relo as an IDE, so I don't know anything about it. If you're using it with the MinGW compiler, I suppose it should be fine. open up a new project and either write or copy and paste your C code. if it's anything like any other … | |
Re: basically the "inner loop" is variable, and will execute a number of times that varies depending on the value of the outer loops. outer loop #1 inner loop executes 1 time outer loop #2 inner loop executes 2 times outer loop #3 inner loop executes 3 times etc. consider also, … | |
Re: it's [B]totally [/B]due to that terrible hack of a "wait" routine. that's it and that's all. the while loop is using [I]every single available CPU cycle[/I] to approximate a timer. Like AD said, you need to use the library function for sleep(), in order to free up the CPU for … | |
Re: you probably want to look into [URL="http://www.google.com/search?q=sparse+matrix+compression"]sparse matrix compression[/URL] algorithms | |
Re: [code=text] [pseudocode] initialize sumOfCubes = 0.0 for a = 1 to 3 { get float input from user store in inputValue initialize cubedValue = 1.0 for b = 1 to 3 { cubedValue = cubedValue * inputValue } print "the cube of " inputValue " is " cubedValue "." sumOfCubes … | |
Re: hi friends i m a comptr eeng. student ı saw your codes then ı felt bad because ı think ı should improve my codes ?so how can improve my codes?ı m 2.class student..thxx don't hijack someone else's thread to feel bad in. formulate a specific, coherent question and go post … | |
Re: Funny thing, Walt, i've noticed your own recent posts where you do exactly the same thing. such as this one here, where your only response to some guy's crap code was to tell him that it's full of problems and he needs to refrain from posting. [QUOTE=WaltP;1151442]Please ignore yila's code. … | |
Re: the recursive stack is because they're trying to teach you a concept, not just so you can 'get it done' you definitely should do it the way that's required even if another way seems easier. i was going to look at this myself, but i'm at work and don't have … | |
Re: i don't get it. is this a question or an order? | |
Re: [QUOTE=alfroad;1155892]hello guys can you give me... [/quote] now that the thread has been moved, the lesson is : DON'T hijack someone else's thread with some completely unrelated question of your own. but please DO rephrase your question in a coherent manner so the rest of us might understand what you're … | |
Re: [b]crappy[/b] (krap' e) - [I]adjective[/I], slang. (1) difficult to implement without requiring an excessive amount of overhead to prevent it from falling apart during normal field use. (2) anything that exists alongside a freely available alternative from the standard library that covers most use scenarios in a manner resistant to … | |
Re: wait, wait... your code prints a full pyramid. [code=text]3= * *** *****[/code] which is way more complicated than printing a half pyramid. [code=text]3= * ** ***[/code] man, how did you figure out a full pyramid but not be able to get the much simpler half pyramid? read what walt said. … | |
Re: [QUOTE=iliali16;1147699]tutorials in C and I seem to grasp some of the ideas of the language but as I learned it is a very messy language.[/quote] C is a very well-defined and highly structured language, probably one of the most structured languages you'll find. there's nothing messy about it. Perhaps your … | |
Re: here's a hint. you can use the function strstr, in a manner similar to this: [CODE]result_ptr = strstr(registrationString,":") printf("the registration number is %s\n",(result_ptr + 1));[/CODE] EDIT: I just noticed your other thread. People here (including me) are very cautious about people coming here wanting work done for them. I dont … | |
Re: [QUOTE]Pls can u guide me hw cud i b a good programmer?[/QUOTE] ... sent from uday's Blackberry Wireless. | |
Re: brilliant first post, osc. | |
Re: n is XOR'ed with an unsigned -1, the resulting value is stored in 'n' -1 is treated as an unsigned integer, meaning just that it's a variable with all bits are ones. a 32-bit int, will be 0xFFFFFFFF basically this is like a microcontroller register operation that "flips" all the … | |
Re: was the C program compiled on Vista, or did you grab an already-compiled .EXE from somewhere else? you need to have compiled the executable on Vista. so yes, you'll need a C-compiler. MS provides a basic, free version of Visual C/C++ | |
Re: i would like to make an observation. obscure variable names, cryptic logic, and peculiar bracket indentations do not lend your code to being easily read by the casual passer-by who might be inclined to scan your code for obvious or hidden errors. this might also explain why for what's otherwise … | |
Re: i shall post in here now, so i can remember to visit it later, when i am "leisurely bored" :) | |
Re: i tend to avoid "do/while" loops. "do" statements are kind of unpopular with most c programmers unless theres a compelling reason to use them. just use a while statement to get the same effect. as for validating floats... stay away from scanf. I would personally input a string, validate that … | |
Re: hello. generally this is just a hey whassup shout out to the new folks. specific questions would be more likely to get a response, if posted in the forums. but welcome. stick around and contribute your questions or answers, whichever you have more of! :) | |
Re: so what's your question? and what have you done so far? go ahead and show us what you've got. here's a handy template: [code] #include <stdio.h> #include <stdlib.h> int main(void) { // paste code here return 0; } [/code] oh, wait? you want hints on how to start? okay, here … | |
Re: well... your question is kind of hard to follow but, i think your confusion might be in your while() statement. for instance: if [iCODE]k=1[/iCODE], and then you say [iCODE]while (k-- > 0)[/iCODE] the statement [iCODE]k-- > 0[/iCODE] is true, because k post-decremented is evaluated while [iCODE]k=1[/iCODE] but then the post … | |
Re: [QUOTE=COKEDUDE;1132853]When you have a function and need to scan for 2 different numbers, should the scanf be in the function or in the main() and why?[/QUOTE] question is flawed. you shouldnt use scanf for user input. use [url="http://www.cplusplus.com/reference/clibrary/cstdio/fgets/"]fgets()[/url] in conjunction with [URL="http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/"]sscanf()[/URL] or [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atol/"]atol()[/URL] or [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atof/"]atof()[/URL] or something similar. see … | |
Re: [QUOTE=gerard4143;1133000]It was written/run once and appeared to work...that's quickly in my books.[/QUOTE] what constitutes "appearing to work" for you? not having the computer crash? if so, then yeah, it "appeared to work". other than that, it was full of compiler warnings and gives nonsensical output. Boo. | |
Re: scanf is a notoriously difficult function to use, especially for beginners. try using fgets in conjunction with atoi instead. [CODE]char strInput[MAX_LEN_INPUT]; int value; fgets(strInput, MAX_LEN_INPUT-1, stdin); value = atoi(strInput);[/CODE] once you figure out this basic method, use strtol instead of atoi, and you can make a pretty bulletproof input routine … | |
Re: [QUOTE]Well, this was probably a bad idea,[/QUOTE] yeah.... it's unfair to the newbie poster to be handed such a lovingly polished solution, and it's unfair to the rest of us here who strive to teach students how to do their own work without handing it to them. it'd be one … | |
Re: [QUOTE=tikoti;1131607]OMG It was a stupide question Thank you for answering! ;)[/QUOTE] i recall some recent snafu at NASA causing a significant failure, and being traced to a divide-by-zero error. (or, maybe i dreamed it. i'm not sure now...) but anyhow it's not a stupid question. it's a good lesson. For … | |
Re: [QUOTE=techno_weenie;1132758]Hello, I'm trying to split a string into 4 separate strings using a delimiter "\n" [/QUOTE] i would suggest that replacing printable characters with '\n' as a delimiter is a Bad Idea. Because what is '\n', anyhow? is it 0x0D ? is it 0x0A ? or is it 0x0D + … | |
Re: swap the product and seller indices [code=text] [pseudo] print columnheaders, newline for p = 1 to NUMPRODS print "product #", p for s = 1 to NUMSELLERS print matrix[s-1][p-1] next s print newline next p done [/pseudo] [/code] . | |
Re: if you want to [b]round[/b] the number, then you use "setprecision(<n>)" or the format specifier "%.<n>f" for "printf()" where <n> is the number of digits you want to round to. E.g., the value 1.66667 rounded to <n>=1 decimal place will be 1.7 but what you really want to do here … | |
Re: once you address what walt said, your first code problem i see is <conio.h> remove that line, and remove everything that depends on it. then rewrite in standard C. until you do that, i doubt anyone here will bother trying to compile and run your code, because no one uses … | |
Re: [quote=swathydoss;1117778]hi....... I want a program in c based on any data structures with de code.plz............it shd be catchy n can be based on reality[/quote] omfg U R 2 cool! wer R U @ a/s/l? Did U gt de CODEZ? snd dem 2 me PLZ! zomgWTFbbq!!!1 lololol . | |
Re: Heres their program's header file [code=c]/** * StopDice.h * Defines constants used for StopDice program logic and graphics * * NOTE that string constants are NOT declared constants in order * to conform to the requirements of WinBGIm functions that do * not define constant string parameters when they should. … | |
Re: you posted this question twice dave. does your program not work? what is your question? | |
Re: i think your changes are inspired by a lot of good ideas :) but like some other i also think it has added the perception of too much clutter. i think the most grievous offender is the row of "share this" "send that" "bookmark" "yadda yadda" buttons... I think they're … ![]() | |
Re: here's a bug: [icode]#include <conio.h>[/icode] your program is worthless with that in it. why do you people insist on clinging onto that Turbo C crap? | |
Re: i thought the Big Bang was actually the Egyptian god, Ptah,who masturbated and his ejaculate became the universe. | |
Re: ^ that may work for you in this instance, but it's not standard C, and will not be portable. thats a realtime clock library that is often found on linux machines, but is not guaranteed by the C standard. for standard C that will work everywhere, use the functions "time()", … | |
Re: [QUOTE=joperalez;1078095]I know this is using C. But if i was using the stdlib.h to use C in C++ ..... trying to find a simple way to add two hex numbers together but in C++;[/QUOTE] I know this is the C forum, but if it were the C++ forum, it would … |
The End.