Software QA (13)
SQL Server (1)
What is the difference between these initializations? ....
What is the difference between these initializations?
char a = "string literal";
char *p = "string literal";
My program crashes if I try to assign a new value to p[i].
A string literal (the formal term for a double-quoted string in C source) can be used in two slightly different ways:
1. As the initializer for an array of char, as in the declaration of char a , it specifies the initial values of the characters in that array (and, if necessary, its size).
2. Anywhere else, it turns into an unnamed, static array of characters, and this unnamed array may be stored in read-only memory, and which therefore cannot necessarily be modified. In an expression context, the array is converted at once to a pointer, as usual 2. , so the second declaration initializes p to point to the unnamed array's first element.
Some compilers have a switch controlling whether string literals are writable or not (for compiling old code), and some may have options to cause string literals to be formally treated as arrays of const char (for better error catching).
2016-03-09, 1116👍, 0💬
How can you raise custom errors from stored procedure ? The RAISERROR statement is used to produce a...
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
What is a fish bone diagram ? Dr. Kaoru Ishikawa, invented the fishbone diagram. Therefore, it can b...
What is the value of this expression? +1-2*3/4 -0.5
Regarding C Coding Given: Line in file Contents 30 int * someIDs, theFirst, *r; 110 someIDs =GetSome...