| |
thread by: Steven Woody |
last post Jan 16 '06 by: Vladimir S. Oka
hi,
after some weeks of development of a project, there likely are many
"#include" in source files which was added before but are now
unnecessary. is there any tool which can find out those "#include"s
and tell me it's safe to remove them? manual work is so time consuming.
thanks.
-
woody
|
thread by: Jeff |
last post Feb 7 '06 by: Vladimir S. Oka
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
thread by: Tomás |
last post May 22 '06 by: Richard Bos
Some programmers treat arrays just like pointers (and some even think that
they're exactly equivalent). I'm going to demonstrate the differences.
Firstly, let's assume that we're working on a platform which has the
following properties:
1) char's are 8-Bit. ( "char" is synomonous with "byte" ).
2) int's are 32-Bit. ( sizeof(int) == 4 )....
|
thread by: jaso |
last post Jul 28 '06 by: Bob Martin
Can you give any comments on this code?
I used one goto, is it bad?
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#define NOT_NULL 1
|
thread by: Jim Cook |
last post Dec 17 '06 by: Randy Howard
I previously had asked if there was an online standards file so I could
read that and answer my own questions without posting here and getting
flamed for not having done my homework.
I was pointed to a file called n1124.pdf which turns out to be a C99
standard. It appears that quoting from that standard makes a lot of
people say "but C99...
|
thread by: fdmfdmfdm |
last post Feb 26 '07 by: David Thompson
This is an interview question and I gave out my answer here, could you
please check for me?
Q. What are the memory allocation for static variable in a function,
an automatic variable and global variable?
My answer: static variable in function and global variable are
allocated in head, and automatic variable is allocated in stack.
Right?
|
thread by: Malcolm McLean |
last post Feb 22 '07 by: Richard Bos
A proposed new function
int alias(void *ptr1, size_t len1, void *ptr1, size_t len2)
Returns true if the pointers overlap.
On most machines it can be trivially implemented. However it has to be a
standard library function because it is not necessarily legal to compare two
address from different objects.
|
| |
thread by: subramanian100in |
last post Mar 14 '07 by: CBFalconer
I saw this question from www.brainbench.com
void *ptr;
myStruct myArray;
ptr = myArray;
Which of the following is the correct way to increment the variable
"ptr"?
Choice 1 ptr = ptr + sizeof(ptr);
|
thread by: klaushuotari |
last post Mar 24 '07 by: =?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
Sorry to bother you, but I just have to.
What about strdup()? It wasn't in standard C run-time library, yet
many apps use it liberally as it was in there.
I don't know if that particular function is included in C99. Not too
difficult to code own version of it, but why it wasn't included in
library in the first place? Is there some...
|
thread by: ***** charles |
last post Apr 6 '07 by: Martin
Hi all,
I would like to know how all of you learned C.
Was it books, Internet, human mentor, class or other?
later,
charles.....
|
thread by: mdh |
last post May 6 '07 by: Ian Collins
Could someone please help me understand p 119 of K&R?
This is a version of qsort that, depending on a command line optional
argument ( -n) sorts lines numerically vs lexicographically.
I think the relevant lines ( well, the ones I am having a problem
with) are as follows.
# include.....
|
thread by: yinglcs |
last post Jul 20 '07 by: Eric Sosman
Hi,
In java, there is an 'indexOf' function in String which does this:
indexOf(String str)
Returns the index within this string of the first occurrence
of the specified substring.
is there anything like that in c?
The closest thing I can find is strchr, but it check for a character,
|
thread by: ¬a\\/b |
last post Sep 11 '07 by: Kelsey Bjarnason
strlen is wrong because can not report if there is some error
e.g.
char *a;
and "a" point to an array of size=size_t max that has no 0 in it
|
thread by: None |
last post Jun 27 '08 by: Gernot Frisch
Hi,
I am a game developer, sometimes "indy" and sometimes for a small-sized
company. I can't speak for all game developers, but everywhere I've ever
seen people working on games, execution speed has always been the most
important constraint in writing code. Writing readable and maintainable
code is important, but takes a back seat to...
|
thread by: Bartc |
last post Jun 27 '08 by: pete
This short program:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int status;
status=fclose(0);
|
| |
thread by: Bill Cunningham |
last post Jun 27 '08 by: santosh
I have written this ob/os oscillator for securities analysis. The only
thing is that the result is always negative. Such as -96. I have looked over
and over this code and it looks fine to me. Is there any trouble?
#include <stdio.h>
#include <stdlib.h>
double os(double price,double ma)
{ double os;
os=price-ma/ma*100;
|
thread by: Gianni Mariani |
last post Oct 16 '08 by: Michael
Do you have a preference on maximum line width for C++ code?
I've seen the craziest debates on this most silly of topic.
I have witnessed engineers spent oodles of time fiddling with line
breaks just to get it right. I find in general a prescriptive rule
makes for markedly less readable code, which unfortunately is a
subjective argument,...
|
thread by: jacob navia |
last post Oct 21 '08 by: Richard Bos
In his web pages, D. E. Knuth wrote this:
(http://www-cs-faculty.stanford.edu/~knuth/iaq.html)
Infrequently Asked Questions
1. Why does my country have the right to be occupying Iraq?
2. Why should my country not support an international court of justice?
3. Is my country not strong enough to achieve its aims fairly?
4. When the leaders...
|
thread by: Newsnet Customer |
last post Jul 19 '05 by: Ron Natalie
Hi,
Statement 1: "A dynamically created local object will call it's destructor
method when it goes out of scope when a procedure returms"
Agree.
Statement 2: "A dynamically created object will call it's destructor when it
is made a target of a delete".
|
thread by: Vladimir Grul |
last post Jul 22 '05 by: Peter Koch Larsen
Hello,
I have a class member function declared as
class some_class {
....
virtual int call(void);
};
Can I use this-> inside the function body?
|
thread by: Robert |
last post Nov 13 '05 by: Richard Heathfield
Alright, here's my situation:
if i use malloc like:
char *mystring;
mystring = (char *)malloc(80);
return mystring;
free(mystring);
|
thread by: Rick |
last post Nov 13 '05 by: goose
Hi,
For portability, can an issue arise if we use while(1) for an infinite
loop in C? If so, should we then use for(;;)? Thanks,
Rick
|
thread by: entropy123 |
last post Nov 13 '05 by: Randy Howard
Hey all,
I'm working with some legacy C code and I would like to compile it as
a CPP file.
I get the following error message:
driver.cpp:87: cannot convert `void *' to `GenericStruct *' in
assignment
|
| |
thread by: Douglas Garstang |
last post Nov 13 '05 by: Richard Heathfield
I can't believe I've been trying to work this out for hours now, and I
can't believe I couldn't find someone asking for a similar solution in
the newsgroups. No wonder I hate C so much, and every time I get the
textbooks out end up throwing them against the wall in rage. Thats
been going on for 10 years now.
Anyway, I have:
typedef...
|
thread by: Christopher Benson-Manica |
last post Nov 14 '05 by: Mark McIntyre
gets() is universally acknowledged to be broken and useless; however,
it is still part of the standard library. Why? Is there enough
conforming code out there using gets() to justify retaining it? Are
there plans to deprecate or eliminate it in a future version?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if...
|