2,384 Posted Topics
Re: Reread your text on basic syntax.[code]int words { int words = 1;[/code]It looks like VB. Functions should have a parenthesized parameter list, and it's not a good idea to name a local variable the same as the function. | |
Re: [URL="http://groups.google.com/group/comp.lang.c/msg/4e0202d03c6291c5"]This is somewhat related[/URL]; I like Chris Torek's explanations of many things: [QUOTE="Chris Torek"]Remember: >>> Precedence and associativity are only for parsing. <<< Do not equate `higher precedence' with `done first at runtime.' >>> Evaluation order is effectively unspecified. <<< Make sure your code does not depend on the actual … | |
Re: [I][B]return-value-type[/B][/I] Any value, or none at all, that you want to return from the function: an error code, a calculated result, etc. [I][B]parameter-list[/B][/I] Any value(s) -- or possibly references in C++, or none at all, that you want to pass to the function: a pointer to an array to calculate … | |
Re: [code]if ( num > max ) { max2 = max; max = num; }[/code] | |
Re: AD: There's no need to cast away constness (it may do no harm, but I avoid things that can be bad habits). And your integer comparison function can be a victim of integer overflow. | |
Re: You've got a lot there that needs tweaking. I first found it confusing how you got typos in what would appear to be a copy-and-paste, but I guess what you posted was an intermediate attempt since it wouldn't even compile. After fixing those and ditching the user input for the … | |
Re: [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048865140&id=1043284351]FAQ > Explanations of... > Definition of EOF and how to use it effectively [/url] | |
Re: Why are you using this form: [INLINECODE](a + i*arraysize +j)[/INLINECODE] rather than subscript notation [INLINECODE]a[i][j][/INLINECODE]? It's simpler, for one, and it is also easier to see that [INLINECODE](a + i*arraysize +j)[/INLINECODE] means the same as [INLINECODE][COLOR="Magenta"]&[/COLOR]a[i][j][/INLINECODE]. Or that [INLINECODE][COLOR="Magenta"]*[/COLOR](a + i*arraysize +j)[/INLINECODE] means the same as [INLINECODE]a[i][j][/INLINECODE]. So what you … | |
Re: >If anyone can help me i would greatly appreciate it. [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385"]Sure[/url]. | |
Re: [QUOTE=Smitha Renny;1125877]Hi As you have said, it is the logic you have used. There is a slight modification I have made in your program and it will show a vowel only as a vowel. Here it is:[/QUOTE] Did you not understand the logic behind using isalpha and toupper, or did … | |
Re: Please read the [url=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/url]. | |
Re: [code] struct amicable* record; /* allocate array of pointers */ record->amicablePair=(int**)malloc(nrows*sizeof(int*));[/code]record needs to point to something before you dereference what it points to with the -> operator. | |
Re: [QUOTE=Veer]3. for that you will have to keep track of all the required information, ex. - real min/max - absolute min/max - absolute sum The problem is I can not use "Array". and i dont know how can i declare 25 numbers?? thts why im confuse[/QUOTE]Input your values to a … | |
Re: [QUOTE=Alfarata]I need to read in a csv file created by MSExcel into an array. The file contains 750 rows of 5 sets of numbers some int. some float. the format looks like this: [code]301,36,0.285,2.88,15.000 302,88,0.247,2.88,75.500[/code][/QUOTE]To me it sounds like you'd want to read a line as a string using [FONT=Courier … | |
Re: What I find funny is that the worst epithets that apply to Palin apply equally if not moreso to Obama. Keep 'em coming! | |
Re: "[url="http://www.eskimo.com/%7Escs/C-faq/q3.2.html"]The behavior of code which contains multiple, ambiguous side effects has always been undefined[/url]". | |
Re: I double my recommendation that you learn the core language before jumping into APIs. | |
Re: Something like [url="http://forums.devshed.com/showthread.php?p=707896#post707896"]this[/url]? | |
Re: [QUOTE=AhmedHan]So, is that the fault of sizeof() or the structure really holds 56 bytes? I am gonna use this structure to gether the header of a bitmap file. My question is, am I gonna get 54 bytes or 56 bytes by a file stream function such as .read() ?[/QUOTE]What [FONT=Courier … | |
Re: Go to the last line of the file, to the last character in the line, and hit return/enter. | |
Many times [inlinecode]strtok[/inlinecode] is recommended for parsing a string; I don't care for [inlinecode]strtok[/inlinecode]. Why? [list][*]It modifies the incoming string, so it cannot be used with string literals or other constant strings. [*]The identity of the delimiting character is lost. [*]It uses a static buffer while parsing, so it's not … | |
Re: # include<alloc.h> - is nonstandard #include<conio.h> - is nonstandard void main() - is incorrect ch=(char*)malloc(20) - the cast is unnecessary, you should check the return value clrscr(); - nonstandard function gets(ch); - never use gets()! return 0; - returning a value from a void function? | |
Never use the function [inlinecode]gets[/inlinecode]. Why? It is unsafe. Since the maximum string size cannot be specified, it is always susceptible to buffer overflow. This snippet shows one way to do a safe version of [inlinecode]gets[/inlinecode]. It reads characters from the [inlinecode]stdin[/inlinecode] into a string up to the specified size … | |
Re: [QUOTE=dalaharp]i have attached a file, where the first step of gabor filter is detailed (a point to note: i am implementing gabor for fingerprint image processing) and this is how i coded it.. just see if there are no technical errors in it..[/QUOTE]We can't really do that because you are … | |
Just to measure this site's preferred candidates, but possibly to stir up another hornets nest. :D [url=http://en.wikipedia.org/wiki/United_States_presidential_election%2C_2008]More info[/url]. [I]The poll had a limit of 10 items. There are more R's than D's because [B]I[/B] made this poll and because that side is more contested.[/I] | |
![]() | Re: [code] int age;[/code]You have [i][font=Courier New]age[/font][/i] declared as a single [font=Courier New]int[/font], but later try to operate on it as if it were an array of [font=Courier New]int[/font]s, which it is not. |
| |
![]() | Re: [QUOTE=ardav;1150525]Is it me or are there loads of members reanimating long-expired threads? [/QUOTE] I read "members" as those who've been here for a while. Isn't it more likely that someone just registered and responds to some 2-year-old question, though? Just a different variant of the fly-by/on-off poster. [QUOTE=ardav;1150525]Is there a … ![]() |
Re: You've got an extra [INLINECODE]}[/INLINECODE] at then end of [I]solve[/I], right before [I]check[/I]. | |
Re: [url="http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=8m9jdm%2498c%241%40bob.news.rcn.net"]http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=8m9jdm%2498c%241%40bob.news.rcn.net[/url] | |
Re: [QUOTE=marinme][code]void FillMyArray(int ArrayToBeFilled[], int TopValueToBeInserted) { for(int i = [COLOR=Red]1[/COLOR]; i<[COLOR=Red]=[/COLOR]TopValueToBeInserted;i++) { ArrayToBeFilled[i] = i; } }[/code][/QUOTE]The usual (and correct) idiom is like this.[code]for(int i = [COLOR=Blue]0[/COLOR]; i [COLOR=Blue]<[/COLOR] TopValueToBeInserted; i++)[/code]An array of size N is indexed from 0 to N-1. | |
Re: With all due respect, "mods don't want to moderate" is a lame excuse. Maybe recruit mods from people who are both knowledgeable in the forum in question AND those who want to play janitor (rather than simply being a frequent poster?)? | |
Re: C or C++? The C solution is [font=Courier New]qsort[/font], and the only difference from what was already shown is the comparison function you write. In C++ there is a [font=Courier New]std::sort[/font].[code]#include <iostream> #include <vector> #include <algorithm> typedef std::vector<std::string>::iterator iter; typedef std::vector<std::string>::const_iterator citer; void Show(std::vector<std::string> &alist, const char *label = "") … | |
Re: [QUOTE=jephthah;1163775]here is the NOW BULLETPROOF(*) version that i should have posted in the first place (* Nearly) [code] char *tempDate, *mmStr, *ddStr, *yyStr, *ptr; int error = 0; tempDate = malloc(strlen(dateString) * sizeof(char)); strcpy(tempDate,dateString); // copy dateStr into temp location that can be abused by strtok [/code] .[/QUOTE] Isn't that … | |
Re: Uh. Follow the links posted already in the thread? (Try not to be an unthinking idiot who is not inclined to read the replies already posted here.) | |
Re: Using char or short for bitfields is a non-standard extension. Prefer doing the shift-and-mask yourself with an unsigned type. | |
Re: [QUOTE=tajendra;1152520]2) Don't use specific system constant. System specific constant should not be used as they are not portable, we are some time not aware of them also. Like system constant "NULL" is specific to windows and will give compilation error on other platform. Instead of "NULL" one can use "0". … | |
Re: Returning a pointer to char is different from returning a char. | |
Re: main.c:55: warning: passing arg 1 of `load_MPN_table' from incompatible pointer type main.c:66: warning: char format, different type arg (arg 2) main.c:50: warning: unused variable `row' | |
Re: Off the top -- watch out for unintended assignment. [code]while ( counter= 0 )[/code]Comparison is [INLINECODE]==[/INLINECODE]. | |
Re: [url]http://c-faq.com/aryptr/dynmuldimary.html[/url] | |
Re: [QUOTE=dumbncool;1155695]Inside a C function, if I declare something like [icode]char *s = "Hello";[/icode] Where will the memory for the "Hello" string be allocated? Will it be on the stack or the heap?[/QUOTE] Neither. [url]http://c-faq.com/aryptr/aryptr2.html[/url] | |
Re: Another link: [url=http://www.daniweb.com/tutorials/tutorial45806.html]User Input: Strings and Numbers [C][/url] | |
Re: Using a subscript operator implies a container of some sort: an array, a vector, a linked list, etc. [URL="http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.12"]Subscript operators often come in pairs[/URL]. In your case, x, y, and z might be seen as elements to your "container" -- to which elements 0, 1, and 2 might be subscript … | |
Re: [QUOTE=habib_parisa;1152545]By the way, why your formula does not work when the malloc is used in a separate line like this: [CODE]double (*tree)[50]; (*tree)[50] = malloc( 50 * sizeof(*tree) ); [/CODE][/QUOTE] As declaration + statement, it would be like this: [CODE] double (*tree)[DIM]; [COLOR="Red"][B]tree [/B][/COLOR]= malloc( DIM * sizeof(*tree) );[/CODE] (Pay … | |
Re: You're using sscanf as if it were fscanf. You can make the two behave similarly, but sscanf will need different directives and variables. |
The End.