QueryCAT Logo
Search 5,000,000+ questions and answers.

Frequently Asked Questions

What's the difference between ''char const *p'' and ''char * const p''?

Infrequently Asked Questions in comp.lang.c
One '' '' character. There are some trivial differences having to do with the distinction between a pointer to a constant, and a constant pointer, but since you can cast either to a (char *) it hardly matters. Can I declare main as void, to shut off these annoying ''main returns no value'' messages? (I'm calling exit(), so main doesn't return.) Certainly. You can also declare it as double.

What's the difference between const char *p, char const *p, and char * const p?

ANSI/ISO Standard C
The first two are interchangeable; they declare a pointer to a constant character (you can't change any pointed-to characters). char * const p declares a constant pointer to a (variable) character (i.e. you can't change the pointer). See similar questions...

What is the difference between char a[] = "string"; and char *p = "string"; ?

Frequently Asked Questions: C Language (abridged)
The first declares an initialized and modifiable array; the second declares a pointer initialized to a not-necessarily- modifiable constant string. See similar questions...

Why can't I convert a char ** to a const char **?

Tech Talk about C++ and C Issues / Comeau C++ and C FAQ
Why can't I convert a char * to a const char *&? The most common response/solution we've seen offered with respect to this issue is that the person with this problem should just use a cast. Unfortunately, there is normally no additional explanation of the matter. So, that's not helpful in understanding the matter. Worse, it can even be considered harmful advice. The second most common response is a blunt "because", but that doesn't help any either. See similar questions...

Why can't I pass a char ** to a function which expects a const char **?

ANSI/ISO Standard C
You can use a pointer-to-T (for any type T) where a pointer-to-const-T is expected. However, the rule (an explicit exception) which permits slight mismatches in qualified pointer types is not applied recursively, but only at the top level. (const char ** is pointer-to-pointer-to-const-char, and the exception therefore does not apply.) The reason that you cannot assign a char ** value to a const char ** pointer is somewhat obscure. See similar questions...

what is the difference between char,varchar,varchar2?

Oracle FAQs - Page 1
Latest Answer: Hello ppl,i think u all r got confused with this char and varchar.here is itchar : will allocate val... See similar questions...

Does "const Fred* p" mean that *p can't change?

Const correctness, C++ FAQ Lite
quot;const Fred* p" means that the Fred can't be changed via pointer p, but there might be other ways to get at the object without going through a const (such as an aliased non-const pointer such as a Fred*). For example, if you have two pointers "const Fred* p" and "Fred* q" that point to the same Fred object (aliasing), pointer q can be used to change the Fred object but pointer p cannot. See similar questions...

I just tried the code char *p; strcpy(p, "abc"); and it worked. How? Why didn't it crash?

Memory Allocation
You got lucky, I guess. The memory randomly pointed to by the uninitialized pointer p happened to be writable by you, and apparently was not already in use for anything vital. See also question 11.35. See similar questions...

Why does this code: char *p = "hello, world!"; p[0] = 'H'; crash?

All Questions
I've got some code that's trying to unpack external structures, but it's crashing with a message about an ''unaligned access.'' What does this mean? The code looks like this: struct mystruct { char c; long int i32; int i16; } s; char buf[7], *p; fread(buf, 7, 1, fp); p = buf; s.c = *p++; s.i32 = *(long int *)p; p += 4; s.i16 = *(int *)p; See similar questions...

What is the difference between const and static readonly?

C# Frequently Asked Questions
The difference is that the value of a static readonly field is set at run time, and can thus be modified by the containing class, whereas the value of a const field is set to a compile time constant. static readonly is typically used if the type of the field is not allowed in a const declaration, or when the value is not known at compile time. See similar questions...

What's the difference between #define and const?

Tech Talk about C++ and C Issues / Comeau C++ and C FAQ
Why is the preprocessor frowned upon? There are a few problems with #define in C and C++, whether the macro is being used as a named constant or as a function-like entity. Among them include: The preprocessor is effectively a separate language from C or C++, and so at some level the compiler really knows nothing about what happened. In effect, the text substitutions that occur happen before the so-called compiler proper phase is invoked. The debugger, error messages, etc. See similar questions...

What is a char?

jGuru: I18N FAQ Home Page
While the char type is basic to the Java language, many programmers stumble over Unicode escapes, values and conversions. The first definition should... See similar questions...

What is the difference between oper flag P and p?

Frequently Asked Questions
Opers with +P cannot be kicked by opers with +p, even if you set +p to be a higher level in the channel than +P. You can give +P different onjoin modes than +p, effectively giving an oper with HighProt (+P) higher privileges (or lower, if you want) than an oper with LowProt (+p). See similar questions...

What's the difference between list::iterator and list::const_iterator?

FAQ
iterator will allow you to change the value that it points at (i.e., it's like an ordinary pointer), whereas a const_iterator won't (i.e., it's like a const pointer). If you ask for an iterator to a const list then you'll get an error. See similar questions...

I want to use a char * pointer to step over some ints. Why doesn't "((int *)p)++;" work?

Frequently Asked Questions: C Language (abridged)
In C, a cast operator is a conversion operator, and by definition it yields an rvalue, which cannot be assigned to, or incremented with ++. I have a function which accepts, and is supposed to initialize, a pointer, but the pointer in the caller remains unchanged. See similar questions...

Explore Other Topics

QUESTION: Are there any steroids or any bonded substance in Ringmaster Rubbing Oil?
Blood in semen... What causes blood in semen?
Do I have to download and install client software on my web site to use your service?
How do you wire the log homes for electricity?
What is the PCAT and is it required?
How do I cancel my E-Z Pay service?
What Is AC?
What is the maximum amount I can deposit?
Can I check my e-mail through your web based e-mail system?
Is there a difference between the centigrade and Celsius temperature scales?
Who is considered the owner of a UTMA/UGMA account?
How can I carry out a Yates' chi-square test?
What's MIDI CC?
Why choose Mechanical Engineering?
More Questions >>

© Copyright 2007-2012 QueryCAT
About • Webmasters • Contact