6.1 I had the definition char a[6] in one source file, and in another I declared extern char *a. Why didn't it work?
6.2 But I heard that char a[] was identical to char *a.
6.3 So what is meant by the ``equivalence of pointers and arrays'' in C?
6.4 If they're so different, then why are array and pointer declarations interchangeable as function formal parameters?
6.4b So arrays are passed by reference, even though the rest of C uses pass by value?
6.5 Why can't I do something like this?
extern char *getpass();
char str[10];
str = getpass("Enter password: ");
6.6 If you can't assign to arrays, then how can
int f(char str[])
{
if(str[0] == '\0')
str = "none";
...
}
work?
6.6b And what about this? Isn't this an array assignment?
char a[] = "Hello, world!\n";
6.7 How can an array be an lvalue, if you can't assign to it?
6.8 Practically speaking, what is the difference between arrays and pointers?
6.9 Someone explained to me that arrays were really just constant pointers.
6.10 I'm still mystified. Is a pointer a kind of array, or is an array a kind of pointer?
6.11 I came across some ``joke'' code containing the ``expression'' 5["abcdef"] . How can this be legal C?
6.12 Since array references decay into pointers, if arr is an array, what's the difference between arr and &arr?
6.13 How do I declare a pointer to an array?
6.14 How can I set an array's size at run time?
How can I avoid fixed-sized arrays?
6.15 How can I declare local arrays of a size matching a passed-in array?
6.16 How can I dynamically allocate a multidimensional array?
6.17 Here's a neat trick: if I write
int realarray[10];
int *array = &realarray[-1];
I can treat array as if it were a 1-based array.
6.18 My compiler complained when I passed a two-dimensional array to a function expecting a pointer to a pointer.
6.19 How do I write functions which accept two-dimensional arrays when the width is not known at compile time?
6.20 How can I use statically- and dynamically-allocated multidimensional arrays interchangeably when passing them to functions?
6.21 Why doesn't sizeof properly report the size of an array when the array is a parameter to a function? I have a test routine
f(char a[10])
{
int i = sizeof(a);
printf("%d\n", i);
}
and it prints 4, not 10.
6.22 How can code in a file where an array is declared as extern (i.e. it is defined, and its size determined, in some other file) determine the size of the array? sizeof doesn't seem to work.
6.23 I want to know how many elements are in an array, but sizeof yields the size in bytes.
6.24 Is there a way to have an array of bits?
Search Your Question
Monday, May 19, 2008
C Interview Questions - Part 12
Subscribe to:
Post Comments (Atom)
Archives
-
▼
2008
(992)
-
▼
May
(474)
- Turtle 1.0 Interview question
- DotNet Framework & IIS installation order Intervi...
- Camps & Medicines are needed more than anything el...
- Executable Jar File in JAVA. Interview quations
- AJAX : Todays Buzz Interview question
- Executable Jar File in JAVA. Interview question
- AJAX : Todays Buzzword Interview question
- AJAX : Todays Buzzword Interview question
- AJAX : Todays Buzzword Interview question
- AJAX : Todays Buzzword Interview question
- What is .Resx file in Dot Net? Interview question
- How to use Microsoft Indexing Service? Interview q...
- Posting data to another ASPX Page Interview question
- Virtual Karma: Complete List of Web 2.0 Applicatio...
- Some Useful Web Links Interview question
- Home automation in the Netherlands Interview question
- Speed Up your web sites with HTTP Compression Inte...
- ASP.NET 2.0 Magic: Asynchronous Web Pages Intervie...
- RSS Puller in ASP Interview question
- ASP.NET: Interview Questions
- Java Interview Questions
- Java Interview Questions
- ASP.net Interview Questions
- PHP Interview Questions
- C Interview Questions
- C++ interview Questions
- ABAP Interview Questions
- SAP Interview Questions
- Resume Preparation Guidelines Interview question
- Salary Negotiation Interview question
- Points to remember Interview question
- Basic .NET Framework Interview question
- Software Testing Interview question
- SQL Server Interview question
- Database Interview question
- JAVA Interview Questions
- .NET Interview Questions
- SQL Server Interview Questions
- C++ Interview Questions
- Investment Management Interview Questions
- SAP-ABAP interview questions
- C Interview Questions Interview question
- Software Testing Interview Questions - Load Runner...
- Software Testing Interview Questions - Win Runner
- Software Testing Interview Questions - Manual
- ASP Interview Questions
- Oracle Interview Questions - Part 1
- VB Interview Questions
- Java Interview Questions
- J2EE Interview Questions
- C Interview Questions
- .net Interview Questions
- Java Interview Questions
- Accounting Interview Questions
- Behavioral Interview Questions Interview question
- Finance Interview Questions Interview question
- Technical &Quantitative Interview Questions Inter...
- ABAP / 4 Interview Questions Interview question
- HR Interview Questions Interview question
- C interview Questions Interview question
- Interview Concepts Interview question
- Oracle Interview Questions - Part 2 Interview que...
- Oracle Interview Questions - Part 3 Interview qu...
- Oracle Interview Questions - Part 4 Interview que...
- Oracle Interview Questions - Part 6 Interview que...
- Oracle Interview Questions - Part 7 Interview que...
- PHP Interview Questions - Part 1 Interview question
- Oracle Interview Questions - Part 8 Interview que...
- Oracle Interview Questions - Part 9 Interview que...
- Oracle Interview Questions - Part 10 Interview qu...
- Oracle Interview Questions - Part 11 Interview qu...
- Oracle Interview Questions - Part 12 Interview qu...
- Interview Tips Interview question
- PHP Interview Questions - Part 2 Interview question
- Dot Net Interview Questions - Part 1 Interview qu...
- J2ME Interview Questions Interview question
- CCNA Interview Questions Interview question
- Dot Net Interview Questions - Part 2 Interview qu...
- Dot Net Interview Questions - Part 4 Interview qu...
- Dot Net Interview Questions - Part 5 Interview qu...
- Dot Net Interview Questions - Part 6 Interview qu...
- Dot Net Interview Questions - Part 7 Interview qu...
- Dot Net Interview Questions - Part 8 Interview qu...
- Dot Net Interview Questions - Part 9 Interview qu...
- Dot Net Interview Questions - Part 10 Interview q...
- Dot Net Interview Questions - Part 11 Interview q...
- Dot Net Interview Questions - Part 12 Interview q...
- Dot Net Interview Questions - Part 14 Interview q...
- Dot Net Interview Questions - Part 15 Interview q...
- PHP Interview Questions - Part 3 Interview question
- PHP Interview Questions - Part 1 Interview question
- Oracle Interview Questions - Part 8 Interview ques...
- Oracle Interview Questions - Part 9 Interview ques...
- Oracle Interview Questions - Part 10 Interview que...
- Oracle Interview Questions - Part 11 Interview que...
- Oracle Interview Questions - Part 12 Interview qu...
- Interview Tips Interview question
- PHP Interview Questions - Part 2 Interview question
- Dot Net Interview Questions - Part 1 Interview que...
- J2ME Interview Questions Interview question
-
▼
May
(474)
No comments:
Post a Comment