78 Posted Topics
Re: float prod() is not a prototype, it's merely a declaration. float prod(int, float) is a prototype. As you have it declared, prod() returns int. You'll need to declare it otherwise in order to use it the way you want to. Also, the usual: <conio.h> is obsolete and nonstandard, main returns … | |
Re: [code] mt = (mytype*)calloc(1, sizeof(mytype));[/code] Better is [code] mt = calloc(1, sizeof *mt);[/code] 1) don't cast the result of malloc() (and friends), because all it does is hide a useful warning; and 2) [icode]sizeof *mt[/icode] is shorter than [icode]sizeof(mytype)[/icode], and you don't have to change it if you later change … | |
Re: There are really two answers to this question: 1) yes and 2) no. Yes, because the cast in this case does no more than make an implicit conversion explicit. It is the same if you do [icode]float x = 12;[/icode] -- you don't need to write [icode]float x = (float)12;[/icode] … | |
Re: [QUOTE=udaykrishnag;1432819]to find the size of image by knowing the height and width....and by knowing the pixel depth...any solutions plz help.....[/QUOTE] What do you mean by "size"? In what units do you intend to measure such a quantity? | |
Re: "i researched about threading but it's too complicated for me" Translation: "I don't feel like doing real work, can somebody pretty please solve my problem for me?" | |
Re: Your first and most obvious error has been mentioned already. Since you haven't said otherwise, I'm assuming you fixed that error, and since you haven't kept complaining, I'm assuming that fixed your problem. If that's the case, could you mark this thread solved? If you're still experiencing difficulties after fixing … | |
Re: [QUOTE=DJSAN10;1427307]If the main() takes 3 arguments i.e. int argc,char * argv[],char *env[] and SINCE C DOES NOT SUPPORT FUNCTION OVERLOADING ,y does the c compiler does not give error for simply void main() //that is no arguments at all OR void main(int argc,char *argv[]) //2 arguments[/QUOTE] There are two things … | |
Re: I'm not seeing any errors... compiles and runs fine, giving meaningful output. It's rather more verbose and less useful than `ls -F`, though. ;) Do you want to change the way the output is printed? I'd prototype main(), give some thought to the 20-character limit, and use fgets for user … | |
Re: Wait... are you trying to get the determinant of a square matrix? | |
Re: [QUOTE=cool_zephyr;1424587]1. open a pointer to a file 2. read the bytes till the end of file using fread() 3. close the pointer[/QUOTE] I can do you one better: 1. Find a forum that discusses C++. 2. Don't append your question to a 4.5 year old thread. 3. Do some research … | |
Re: I beg to differ. malloc is defined in some implementation-defined library and declared in <stdlib.h>. | |
Re: Interactively, use fgets() to get a line, then strtol() to convert it to a long. If you're reading from structured input, use scanf(). @alexchen: C is not the same as C++. Please take that cin nonsense somewhere else. | |
Re: If you're using Cygwin, it's probably best to say it upfront -- avoids confusion. For clarification, can you tell us whether fopen returns NULL when you open the file in a subdirectory? | |
Re: [QUOTE=anraevlus18;1418567]Hi Manimuthu, Thanks for your reply..But this logic even i have tried. I wanted to use one single grep command for both operations. Is there a way to do this?[/QUOTE] My advice? Don't bother, unless it's a serious performance barrier (in which case I suspect you wouldn't want to keep … | |
Re: Sorry, missed the second page. Everything I had to say has been said | |
Re: Every integer you pass to printf is sizeof(int) in size, unless it promotes bigger -- you can't pass anything smaller. The only way to print a 24 bit object is to write your own routine with putchar(). OTOH, you could use 3 chars. | |
Re: [QUOTE=terabyte;1414823]Thanks I will give it a look. [...] That is why I'm learning Perl[/QUOTE] Good choice, on both counts p.s. I also recommend K&R, but I'm not sure what other books would be advisable. Most of my knowledge comes from lurking in comp.lang.c | |
Re: Google suggested [url]http://docstore.mik.ua/orelly/perl/prog3/ch21_04.htm[/url] There's a chapter about this topic in [i]Programming Perl[/i] IIRC, but my copy is in another state, so I can't look it up atm. | |
Re: It's not too difficult. count is just a distraction. b starts at 10 and increments until ugly_string[b + 21] is 0. So the useful part of the string is from ugly_string[31] to the end; the first 31 chars are padding just to obfuscate it. a is set to the next … | |
Re: [QUOTE=ravenous;1418608]Also, you don't need [code] struct stacktype s1; [/code] on line 62, you can just use [icode]stacktype s1[/icode].[/QUOTE] Only in C++. Please don't do that in C. | |
Re: [QUOTE=alexchen;1418616]1 [CODE]int *list int main(){ list=new int[size]; for(int i=0;i<size;i++){ list[i]=0; cout<<list[i]<<endl; } } [/CODE][/QUOTE] That's not C. | |
Re: Two words for the same thing. I'm sure there are some people who draw differences and say "it's only an emulator if it does this", etc., but there's no official rule. I tend to use "simulation" to refer to hardware, like a flight simulator, and "emulation" to refer to software, … | |
Re: Well, it's not [I]really[/I] a two-dimensional array -- it's a pointer to (the first element of an array of) pointer to (the first element of an array of) short. The comp.lang.c FAQ, [URL="http://c-faq.com/aryptr/index.html"]section 6[/URL], might help you understand, especially question 6.16. | |
Re: Here's what my first-guess algorithm looks like: 1. Start copying characters from name to newName, keeping track of the number of spaces you encounter. 2. When you encounter the (m-1)th space, copy the remaining characters up through the (n-1)th space into a temporary buffer. 3. Copy the nth word from … | |
Re: Postfix operators bind more tightly than prefix operators. Therefore your [icode]*length++[/icode] gets parsed as [icode]*(length++)[/icode], which has undefined behavior because length + 1 isn't a pointer to the same object. | |
Re: I don't know where to start. Are you using C or C++? You can't use <iostream> in C, but "delete" is a reserved word in C++. Neither language has <conio.h> (which is an archaic and non-standard header) or void main(). Your input problems are something else altogether, but you need … | |
Re: [QUOTE=manish250;1413744]dear all i am new to perl. when i run my basic perl program as follows[CODE]print<<EOF; HELLO MY NAME IS MANISH ARORA EOF[/CODE] i am getting this error Can't find string terminator "EOF" anywhere before EOF at PERL.plx line 1. please help[/QUOTE] Sounds like there's a stray space after the … |
The End.