Some Questions.

G

GeorgeRXZ

Hi Friends,

I have some questions related to C Language.

1> What is the difference between the standard C language and Non
standard C language ?

2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

4> Which is latest version of C ? and who makes changes to the
language Syntax and Add new features or upgrade the language ?



I have written some programs in C language and have uploaded the
source codes to my website.

http://zsoftwares.googlepages.com/CPrograms.html
http://zsoftwares.googlepages.com/DSFPrograms.htm

I have used Turboc compiler (borland International) for writing and
executing all source programs in C on above website. All source code
run properly and gives output under Windows / DOS platform.( Turboc
Compiler). But these programs don't run on compiler of linux os why
this happens ?

[I am student of Computer Engg.]
you can mail me at (e-mail address removed)

GEOrgE
 
R

Richard Heathfield

GeorgeRXZ said:
Hi Friends,

I have some questions related to C Language.

1> What is the difference between the standard C language and Non
standard C language ?

Standard C is C. "Non-standard C" is something that isn't C.
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

The C language doesn't care which platform you use.
3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

C doesn't define Conio.h. If you want one, write your own.
4> Which is latest version of C ?

The barely-implemented ISO/IEC 9899:1999.
and who makes changes to the
language Syntax and Add new features or upgrade the language ?
ISO.

I have written some programs in C language and have uploaded the
source codes to my website.

http://zsoftwares.googlepages.com/CPrograms.html
http://zsoftwares.googlepages.com/DSFPrograms.htm

I have used Turboc compiler (borland International) for writing and
executing all source programs in C on above website. All source code
run properly and gives output under Windows / DOS platform.( Turboc
Compiler). But these programs don't run on compiler of linux os why
this happens ?

I looked at the list of problems you claim to have solved, and there's no
reason why any of them can't be solved in a way that works on both Windows
and Linux, using the C language.

Then I looked at your code. As well as being poor C, it unnecessarily uses
non-standard language and library extensions. Remove these and tidy up the
C itself, and you will find that you are able to port the code to Linux
effortlessly.
 
G

GeorgeRXZ

GeorgeRXZ said:




Standard C is C. "Non-standard C" is something that isn't C.


The C language doesn't care which platform you use.


C doesn't define Conio.h. If you want one, write your own.


The barely-implemented ISO/IEC 9899:1999.


I looked at the list of problems you claim to have solved, and there's no
reason why any of them can't be solved in a way that works on both Windows
and Linux, using the C language.

Then I looked at your code. As well as being poor C, it unnecessarily uses
non-standard language and library extensions. Remove these and tidy up the
C itself, and you will find that you are able to port the code to Linux
effortlessly.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

Mr. Richard Heathfield. thanks for your feedback. But My questions
remained unanswered I don't need remark on my source codes (good or
bad).

I expect you to give answers of my four Questions.

1> What is the difference between the standard C language and Non
standard C language ?


2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?


3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?


4> Which is latest version of C ? and who makes changes to the
language Syntax and Add new features or upgrade the language ?

GEOrgE
 
J

jacob navia

GeorgeRXZ said:
1> What is the difference between the standard C language and Non
standard C language ?

A fully compliant program will not use any compiler extensions.
Standard extensions are common, and most programs use them.

A fully compliant program will only use the features included in the C
standard. This standard was published in 1999 and it is called C99.

You can buy the standard document from ANSI/ISO.
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

C is not dependent from a single operating system, so you will
be able to use C code as well as in windows as in linux.
Linux C is well supported. Windows C is well supported too.

You should define what is "better" before asking here what is "better".

Better for what?
3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

Yes, but there are compilers that provide a compatibility layer for
conio.h. The lcc-win32 compiler provides an emulation of the
Borland interface under windows. You can download that compiler
at no cost from http://www.cs.virginia.edu/~lcc-win32.
Note that there is no conio.h in the linux version of the same
compiler. You should use the ncurses library to have an equivalent
functionality.
4> Which is latest version of C ?

The standard of 1999, published by ISO/ANSI.

and who makes changes to the
language Syntax and Add new features or upgrade the language ?

There is a committee that decides the standardization of features,
publishes the standard, and in general takes care of those
aspects of C. This is the standards committee.

Normally, before a feature is standarddized, it is (by definition)
non-standard, and doesn't belong to the official language yet.

For instance, the standard of C99 defined variable length arrays after
one popular compiler had introduced that feature as an extension.
This brings us back to your first question. Most compilers propose
extensions, that are not part of the official language but are
part of C as it is used outside the official definition.
 
M

Mark Bluemel

GeorgeRXZ said:
Mr. Richard Heathfield. thanks for your feedback. But My questions
remained unanswered I don't need remark on my source codes (good or
bad).

He did answer your questions, interleaving his responses with your
questions in his posting.

If you didn't understand his answers you should have asked for
clarification.

As for not needing remark on your source code, you asked why you
couldn't port it to Linux, so you must have expected people to examine it...
 
K

Keith Thompson

When you post a followup, it's rarely necessary to quote the entire
previous article. Delete anything that's not relevant to your
followup. In particular, don't quote the signature (the stuff
following the "-- " line) unless you're actually commenting on it.
Mr. Richard Heathfield. thanks for your feedback. But My questions
remained unanswered I don't need remark on my source codes (good or
bad).

The only way to avoid comments on your source code is to hide it.
Richard gave you some good advice. (Disclaimer: I haven't looked at
your source code myself, but I'm certain that his advice was good.)
I expect you to give answers of my four Questions.

The way you phrased that makes it sound like you're giving orders.
I hope that wasn't the way you meant it. Nobody here is obligated to
help you.
1> What is the difference between the standard C language and Non
standard C language ?

He already answered that. The C language is defined by the ISO
standard(s). There are a number of non-standard dialects that are
similar to C; each one differs from C in its own ways.
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

The actual language is the same. Various implementations may provide
different extensions; neither is "better". If you want more
information about Linux or Unix, ask in comp.unix.programmer; for
Windows or DOS, try a newsgroup that deals with those systems.
3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

Because said:
4> Which is latest version of C ? and who makes changes to the
language Syntax and Add new features or upgrade the language ?

Richard already answered that: ISO. (ISO is the International
Organization for Standardization <http://www.iso.org/>.)
 
P

Prayag Narula

Mr. Richard Heathfield. thanks for your feedback. But My questions
remained unanswered I don't need remark on my source codes (good or
bad).

Well, if you cannot accept criticism, please do not post your code for
analysis. It takes a long time to learn how to write portable and
efficient code and people here at clc (like Richard) are the experts
at it and willing to help for free. Accept their comments graciously.
Just a friendly advice.
I expect you to give answers of my four Questions.

1> What is the difference between the standard C language and Non
standard C language ?

Standard C is the language that complies to the ISO standards. I have
never heard of anything called Non-standard C. May be any platform
specific code written in C can be called Non Standard C
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

If you write portable code, all you would need is to recompile the
code on any supported platform. So, it really doesn't matter. Though
it might depend on your application as there are many things you can
only do using platform specific system calls.
3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

conio.h is not a standard header. It is an old MS-DOS a few MS-DOS
specific header which is not used anymore
..
4> Which is latest version of C ? and who makes changes to the
language Syntax and Add new features or upgrade the language ?

ISO last released the standards in 1999, though as Richard said, it
hasn't been implemented widely.


Regards,
Prayag Narula
 
K

Keith Thompson

jacob navia said:
A fully compliant program will not use any compiler extensions.
Standard extensions are common, and most programs use them.

A fully compliant program will only use the features included in the C
standard. This standard was published in 1999 and it is called C99.

You can buy the standard document from ANSI/ISO.

Or from your national standard body.

But it's important to be aware that there are very few full
implementations of the C99 standard. The older C90 standard is much
more widely supported. (Even lcc-win32 doesn't fully support C99.)

[...]
The standard of 1999, published by ISO/ANSI.

Why mention ANSI? The C99 standard was published by ISO; ANSI (the
American National Standards Institute) merely adopted it.

[...]
 
C

Chris Hills

Hi Friends,

I have some questions related to C Language.

1> What is the difference between the standard C language and Non
standard C language ?

C is defined in an ISO standard. These have been issued in 1990 (C90)
with updates in 91,93,95 (C95) and the Current version in 1999 (C99)

However most compilers have implemented C95 and are still "working
towards" C99.

C has no io, no screen, no keyboard etc it has no registers, interrupts
or hardware. Therefore virtually all C compiler have extensions to the
language or the library to cater for the environment they are aimed at.

For some environments it is impossible to write a sensible or efficient
program using purely standard C

So all C compilers have some non-standard C extensions.
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

Neither. That said there are better C compilers under windows than Linux
as most of the top quality embedded or cross compilers run on Windows.
They are not, however designed to write code for windows but other MCU.

If you want to know whether MS Windows or Linux have the better
compilers there is no answer. It is a religious not an engineering
debate :)
3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

Conio.h is one of the extensions or "non-standard c" additions used to
write to the console (screen) in windows. Linux will have other
similar files that are not used in Windows.
4> Which is latest version of C ? and who makes changes to the
language Syntax and Add new features or upgrade the language ?

The latest version of C is ISO9899:1990 (+ Technical corridengum1, +TC2,
+TC3) however no one has fully implemented this in any compiler.

The language is decided by an ISO working group WG14 which is made up
with representatives of (I think) about 25 National Bodies or NB's

The NB's meet typically 3-4 times a year and the ISO Working group twice
a year for a week each time.

Obviously a lot of work goes on by email in between There are
proposals, work items and votes. It takes time.
I have used Turboc compiler (borland International)

This is a good (if obsolete) C compiler system. Many will tell you it is
better them the comparable Microsoft system.
for writing and
executing all source programs in C on above website. All source code
run properly and gives output under Windows / DOS platform.( Turboc
Compiler). But these programs don't run on compiler of linux os why
this happens ?

These programs are written for the DOS environment. You use different
libraries eg conio.h and will have compiled it to run under DOS. an EXE
file.

TO run under Linux you will need a Linux compiler.
 
C

Chris Hills

Chris Hills said:
The latest version of C is ISO9899:1990 (+ Technical corridengum1,
+TC2, +TC3) however no one has fully implemented this in any compiler.


That should be 9899:1999 + TC1,2,3
 
M

Mark Bluemel

Chris said:
These programs are written for the DOS environment. You use different
libraries eg conio.h and will have compiled it to run under DOS. an EXE
file.

TO run under Linux you will need a Linux compiler.

And to adapt the parts which depend on non-standard extensions (e.g.
conio.h) to use the equivalent functionality on Linux (e.g. ncurses).
 
J

James Kuyper Jr.

GeorgeRXZ said:
Mr. Richard Heathfield. thanks for your feedback. But My questions
remained unanswered I don't need remark on my source codes (good or
bad).

I expect you to give answers of my four Questions.

1> What is the difference between the standard C language and Non
standard C language ?

The shortest complete description of non-standard C is to include a
complete copy of the C standard. Any C compiler which does not match
that description is compiling a non-standard version of the C language.

Don't expect a complete list of the ways in which different non-standard
versions of C differ from standard C; that list would be thousands of
pages long.
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

The answer is "Yes". If that doesn't seem like a valid answer, that's
because you don't understand what's wrong with the question you're asking.

First of all, the C language is the C language, regardless of what
operating system you're using it on. The only thing you can reasonably
ask that is operating system dependent is "which is better, C compilers
for Linux or C compilers for Windows/DOS".

Second problem. Notice that I said "C compilers for Linux" NOT "the
Linux C compiler". That's because there are many different compilers for
both operating system. The answer will be different for different
compilers. The only way you can ask the question with any hope of
getting a meaningful answer is if you ask about a specific Linux
compiler and a specific Windows/DOS compiler.

However, you still can't get a meaningful answer, because you haven't
defined what you mean by better. Do you mean "faster compilation",
"faster executable", "more reliable", "smaller compiler", "smaller
executable", "better diagnostic messages", "better technical support",
"lower cost", something else entirely, or some combination of the above?

Finally, for most of the meanings I listed above for "better", the
answer may depend upon the computer hardware you're using, the
particular program you want to compile, and in some cases it depends
upon which inputs you give to that program. It can also depend upon how
many other users are using the system at the same time you are. There's
no single right answer. The only way to be sure is to do a test run with
a particular program, with particular inputs, on a particular platform.
Keep in mind that whatever test results you get will not necessarily
apply to any other program, any other set of inputs, or any other
platform. You won't even necessarily get the same test results the next
time you use the same program on the same platform with the same inputs.

3> Under Linux Platform why Conio.h and and many other header files
are not available in C Language Compiler ?

While you can use those header files in C programs for Windows, they are
not part of the standard C language, but part of the Windows/DOS
operating system. Different facilities are used under Linux to achieve
similar purposes. In general, there is no exact Linux replacement for
any given Windows facility (and vice-versa) - they are organized
differently with different interfaces in the different operating systems.
4> Which is latest version of C ? and who makes changes to the
language Syntax and Add new features or upgrade the language ?

As far as I could tell, it was perfectly accurate and complete. If you
didn't find it helpful, could you please explain why?
 
C

Chris Hills

Mark Bluemel said:
Chris said:
And to adapt the parts which depend on non-standard extensions (e.g.
conio.h) to use the equivalent functionality on Linux (e.g. ncurses).

Actually as there is curses for both dos and linux he might be better
with a "standard" curses that will work on either platform. By which I
mean use the same API on both.
 
R

Richard Bos

Chris Hills said:
Actually as there is curses for both dos and linux he might be better
with a "standard" curses that will work on either platform. By which I
mean use the same API on both.

Actually, since almost none of his code needs or gains (and IMO often
loses) from the use of conio, he should just dike it out. And while he's
doing that, solve the rest of the gratuitous non-portable bits. After
that, he may be ready to tackle the actual bugs he has.

Richard
 
R

Richard Heathfield

James Kuyper Jr. said:
GeorgeRXZ wrote:


While you can use those header files in C programs for Windows, they are
not part of the standard C language, but part of the Windows/DOS
operating system.

Actually, conio.h is not part of Windows or DOS (although I see what you're
getting at). Rather, it is a header name that has been adopted by several
different implementors (at the very least, Microsoft, Borland, and Delorie
- but probably others too) to describe a header that provides interfaces
to DOS and (later) Windows operating system functionality.

Unfortunately, these interfaces are not standardised, so even something as
simple as clearing the screen will differ between implementations. For
example, with Borland you call clrscr, whereas in early Microsoft
implementations you call something like _gclearscreen - although I could
easily be misremembering the precise function name.

<snip>
 
O

osmium

GeorgeRXZ said:
2> which is better C Lanugage, C under Linux/ Unix or C under
windows/ DOS ?

The C *language* is operating system neutral. So the language doesn't
change, the implementation of the language changes. Implementation, as used
above, is code for the compiler and associated "stuff" and the hardware.

If you reworked your question so it could *have* an answer, flipping a coin
would probably be just as useful as any answer you are likely to get on a
newsgroup.

You list four operating systems, if you asked which one of *them* is better,
you would then have to define better to get an answer.

And so it goes.
 
R

Richard

Don't be ridiculous.

That is not what he asked.

Are you being purposely obstructive again? conio does exist. as does
curses. Why would he write his own?

Why?
 
K

Kenneth Brody

Richard Heathfield wrote:
[... conio.h ...]
Unfortunately, these interfaces are not standardised, so even something as
simple as clearing the screen will differ between implementations. For
example, with Borland you call clrscr, whereas in early Microsoft
implementations you call something like _gclearscreen - although I could
easily be misremembering the precise function name.

<mega_OT>

Under Windows, Microsoft's documentation lists no "clear screen"
function. Nor does the <conio.h> include file have reference to
anything that sounds like "clear screen".

In fact, the documentation says:

Some non-Microsoft versions of C++ provide a clrscr function
for clearing the screen in a DOS application. However, there
is no Win32 Application Programming Interface (API) or
C-Runtime function that will perform this function.

However, the same documentation does provide a code sample on how
to clear the screen in a console application.

==========

/* Standard error macro for reporting API errors */
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \
on line %d\n", __FILE__, GetLastError(), api, __LINE__);}

void cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 }; /* here's where we'll home the
cursor */
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
DWORD dwConSize; /* number of character cells in
the current buffer */

/* get the number of character cells in the current buffer */

bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
PERR( bSuccess, "GetConsoleScreenBufferInfo" );
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

/* fill the entire screen with blanks */

bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
dwConSize, coordScreen, &cCharsWritten );
PERR( bSuccess, "FillConsoleOutputCharacter" );

/* get the current text attribute */

bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
PERR( bSuccess, "ConsoleScreenBufferInfo" );

/* now set the buffer's attributes accordingly */

bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten );
PERR( bSuccess, "FillConsoleOutputAttribute" );

/* put the cursor at (0, 0) */

bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
PERR( bSuccess, "SetConsoleCursorPosition" );
return;
}

=========

Couldn't be simpler, n'est pas[*]?

On the other hand, they also include this example:

system("cls");

(KB99261)

</mega_OT>


A perfect example of why "how do I clear the screen" cannot be
answered in Standard C.


[*] Okay, so I don't actually speak French. I hope I got it right.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 
K

Kenny McCormack

Don't be ridiculous.

Welcome to clc. Hope you enjoy your stay.
That is not what he asked.


Are you being purposely obstructive again? conio does exist. as does
curses. Why would he write his own?

C is case sensitive.

(Yes, he was being intentionally stupid/obstructive)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top