[Q19.1 How can I read a single character from the keyboard...]
Note that the answers are often not unique even across different
variants of a system; bear in mind when answering system-
---
Note that the answers may differ even across variants of
otherwise similar systems (e.g. across different variants of
Unix); bear in mind when answering system-specific questions
that the answer that applies to your system may not apply to
everyone else's.
==========
[Q19.3 How can I display a percentage-done indication...]
current line. The character '\b' is a backspace, and will
usually move the cursor one position to the left.
---
usually move the cursor one position to the left. (But remember
to call fflush(), too.)
==========
[Q19.8 How can I direct output to the printer?]
Under some circumstances, another (and perhaps the only)
possibility is to use a window manager's screen-capture
function, and print the resulting bitmap.
==========
[Q19.10 How can I do graphics?]
A modern, platform-independent graphics library (which also
supports 3D graphics and animation) is OpenGL. Other graphics
standards which may be of interest are GKS and PHIGS.
==========
[Q19.12 How can I find out the size of a file, prior to reading it in?]
You can fseek() to the end and then use
ftell(), or maybe try fstat(), but these tend to have the same
sorts of problems: fstat() is not portable, and generally tells
you the same thing stat() tells you; ftell() is not guaranteed
to return a byte count except for binary files. Some systems
---
to return a byte count except for binary files (but, strictly
speaking, binary files don't necessarily support fseek to
SEEK_END at all). Some systems provide functions called
filesize() or filelength(), but these are obviously not
portable, either.
==========
[Q19.20 How can I read a directory in a C program?]
(MS-DOS also has FINDFIRST and FINDNEXT routines which
do essentially the same thing.)
---
do essentially the same thing, and MS Windows has FindFirstFile
and FindNextFile.)
==========
[Q19.23 How can I allocate arrays or structures bigger than 64K?]
to allocate huge amounts of it contiguously. (The C Standard
does not guarantee that single objects can be 32K or larger,
or 64K for C9X.) Often it's a good idea to use data
---
or 64K for C99.) Often it's a good idea to use data
==========
[Q19.25 How can I access memory (a memory-mapped device...]
Then, *magicloc refers to the location you want.
---
Then, *magicloc refers to the location you want. If the
location is a memory-mapped I/O register, you will probably also
want to use the volatile qualifier.
==========
[Q19.27 How can I invoke another program...]
Depending on your operating system, you may also be able to use
system calls such as exec or spawn (or execl, execv, spawnl,
spawnv, etc.).
==========
[Q19.37 How can I implement a delay... with sub-second resolution?]
A: Unfortunately, there is no portable way. V7 Unix, and derived
systems, provided a fairly useful ftime() function with
resolution up to a millisecond, but it has disappeared from
System V and POSIX. Other routines you might look for on your
---
A: Unfortunately, there is no portable way. Routines you might
look for on your system include clock(), delay(), ftime(),
gettimeofday(), msleep(), nap(), napms(), nanosleep(),
setitimer(), sleep(), Sleep(), times(), and usleep().
==========
[Q19.40 How do I... Use sockets? Do networking?]
and W. R. Stevens's _UNIX Network Programming_. There is also
plenty of information out on the net itself, including the
"Unix Socket FAQ" at http://kipper.york.ac.uk/~vic/sock-faq/
---
"Unix Socket FAQ" at http://www.developerweb.net/sock-faq/
and "Beej's Guide to Network Programming" at
http://www.ecst.csuchico.edu/~beej/guide/net/.
(One tip: depending on your OS, you may need to explicitly
request the -lsocket and -lnsl libraries; see question 13.25.)
==========
[Q20.14 Are pointers really faster than arrays?]
It is "usually" faster to march through large arrays with
---
For conventional machines, it is usually faster to march through
large arrays with pointers rather than array subscripts, but for
some processors the reverse is true.
==========
[Q20.20 Why don't C comments nest? ...]
Note also that // comments, as in C++, are not yet legal in C,
so it's not a good idea to use them in C programs (even if your
compiler supports them as an extension).
---
Note also that // comments have only become legal in C as of
C99.
==========
20.20b: Is C a great language, or what? Where else could you write
---
20.21b: Is C a great language, or what? Where else could you write
something like a+++++b ?
==========
[Q20.27 ... Can I use a C++ compiler to compile C code?]
compilation modes. See also questions 8.9 and 20.20.
---
compilation modes. (But it's usually a bad idea to compile
straight C code as if it were C++; the languages are different
enough that you'll generally get poor results.) See also
questions 8.9 and 20.20.
==========
20.32: Will 2000 be a leap year? Is (year % 4 == 0) an accurate test
for leap years?
---
20.32: Is (year % 4 == 0) an accurate test for leap years? (Was 2000 a
leap year?)
A: Yes and no, respectively. The full expression for the present
Gregorian calendar is
---
A: No, it's not accurate (and yes, 2000 was a leap year).
The full expression for the present Gregorian calendar is
==========
[Q20.34 ...how do you write a program which produces its own source code...?]
(This program, like many of the genre, neglects to #include
stdio.h, and assumes that the double-quote character " has the
---
(This program has a few deficiencies, among other things
neglecting to #include stdio.h, and assuming that the double-
quote character " has the value 34, as it does in ASCII.)
Here is an improved version, posted by James Hu:
#define q(k)main(){return!puts(#k"\nq("#k")");}
q(#define q(k)main(){return!puts(#k"\nq("#k")");})
==========
[Q20.35 What is "Duff's Device"?]
A: It's a devastatingly deviously unrolled byte-copying loop,
devised by Tom Duff while he was at Lucasfilm. In its "classic"
form, it looks like:
---
A: It's a devastatingly devious way of unrolling a loop, devised by
Tom Duff while he was at Lucasfilm. In its "classic" form, it
was used to copy bytes, and looked like this:
==========
[Q20.38 Where does the name "C" come from, anyway?]
A: C was derived from Ken Thompson's experimental language B, which
was inspired by Martin Richards's BCPL (Basic Combined
Programming Language), which was a simplification of CPL
(Cambridge Programming Language).
---
(Combined Programming Language, or perhaps Cambridge Programming
Language).
==========
[Q20.40 Where can I get extra copies of this list?]
What about back issues?
This list is an evolving document containing questions which
have been Frequent since before the Great Renaming; it is not
just a collection of this month's interesting questions. Older
copies are obsolete and don't contain much, except the
occasional typo, that the current list doesn't.
Search Your Question
Monday, May 19, 2008
C Interview Questions Part - 4
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