Journal Articles
Browse in : |
All
> Journals
> CVu
> 125
(21)
|
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Questions and Answers
Author: Administrator
Date: 07 September 2000 13:15:40 +01:00 or Thu, 07 September 2000 13:15:40 +01:00
Summary:
Body:
One of the purposes of this column is for the readers to supply the answers. That is why it is in the Dialogue section. Unfortunately, hopefully, only because of the delay in distribution of the previous issue, no one has provided any answers. Of course, I could sit down and write some, or appeal to one of the regular writers to do so. As you can see, I did not do so.
Here is another batch of questions. Your answers to these, or to those previously published will be most welcome. preferably before 1st November.
Jun Woong <mycoboco@hanmail.net>
These are questions about C.
-
If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external. (The K&R says just that such a declaration is tentative definition.)
-
The declaration of an identifier for a function that has block scope shall have no explicit storage-class specifier other than extern'
However, I cannot find that rule in K&R 2nd edition. Is it not mentioned there?
-
Why does the standard disallow storage-class specifiers other than extern on a function declaration inside a block?
-
Regarding arguments that are subject to macro expansion, on #pragma and #error
In "C:A Reference Manual (H&S)", it says that:
"The argument to #pragma is subject to macro expansion.
"The #error directive produces a compile-time error message that will include the argument tokens, which are subject to macro expansion."
Please give me examples about these. I would like to know how the #error directive can have arguments subject to macro expansion.)
Dave Midgley <dave.midgley@uk.york.com>
Here is a question which looks straightforward, but three out of three experienced C/C++ programmers in my office (one of which was me) got it wrong:
int x = 10; for (int y=0, x=0; y < 2; x++; y++) { }
What is the value of x following exit from the for-loop? When you have answered that, compare the following:
int x = 10; int y; for (y=0, x=0; y < 2; x++; y++) { }
Answer is 10 in the first case, because the x in the for loop is a new declaration and is out of scope outside the for-loop. In the second case it is 2, (as we wrongly expected for case 1 as well)
I assume this is correct compiler behaviour, but it is somewhat unexpected. Any comment from the experts? (Compiler is Borland CPP Builder 4)
I need to open files that have statistical data in columnar format such as:
~~~~~~
10 55
20 79
30 50
40 12
~~~~~~
I have a way to read two columns with:
fscanf(fp,"%d %d",xValue,yValue);
However, I need to be able to input from files with various numbers of columns (3,4,5...n, etc.) And store each extra column into a different array. It is quite obvious what will happen if you give the previous function a 3-column file so I thought maybe there is a way to analyse the first string of the file with fscanf() until it comes to a newline, then return the number of values counted. So I messed around with that idea all day long and have still come up short. Is there a library function for stuff like this or do I just not know enough about fscanf() to be able to do it?
Notes:
More fields may be available via dynamicdata ..