I need your advices about C prg.


D

Dogukan Bayraktar

Hi there!

Firstly, sorry for my bad English :/

I'm only 17 and I want to learn C and write perfect codes in C. I'm not so good in C programming, but I want to become a good C programmer.

My English is not enough to read the programming articles or anything.
What should I do to become a good C programmer?

- Do you think is English needed for programming?
- What should I learn in C to become a good programmer?
- Should I read the example C codes in the web?
- etc ... ?

I've been waiting your answers.. Please answer to my questions as soon as possible..

* Thanks ~ !
 
Ad

Advertisements

J

Jens Stuckelberger

Hi there!

Firstly, sorry for my bad English :/

I'm only 17 and I want to learn C and write perfect codes in C. I'm not
so good in C programming, but I want to become a good C programmer.

My English is not enough to read the programming articles or anything.
What should I do to become a good C programmer?

- Do you think is English needed for programming? - What should I learn
in C to become a good programmer? - Should I read the example C codes in
the web? - etc ... ?

I've been waiting your answers.. Please answer to my questions as soon
as possible..

* Thanks ~ !

As a non-native English speaker myself I have to say that your
written English is not so bad; mine was certainly worse when I was 17. If
you can read English as you can write it you should be able to learn from
any standard textbook on C. Don't be afraid and try it. I am sure other
members of this forum, far more C-knowledgeable than me, will give you
relevant references.
 
J

James Kuyper

Hi there!

Firstly, sorry for my bad English :/

I'm only 17 and I want to learn C and write perfect codes in C. I'm not so good in C programming, but I want to become a good C programmer.

Trying for "perfect" is just setting yourself up for a lifetime of
disappointment. "good", on the other hand, is quite feasible. I
recommend trying to become an "expert" C programmer; it's an achievable
but challenging goal.
My English is not enough to read the programming articles or anything.
What should I do to become a good C programmer?

Finding a forum in your native language devoted to C programming would
be best. Depending upon what language that is, that might be difficult,
bordering on impossible. You might have to improve your English. My
wife's native language is Mandarin, and she's studying accounting. The
hardest part for her isn't the math, but the fact that all of the text
books are written in a very advanced, technically oriented dialect of
English. I suspect you'll have similar trouble with C if you can't find
good text books in your native language.
- Do you think is English needed for programming?

It shouldn't be - but as I'm a native speaker of English I wouldn't have
noticed if there are serious barriers for non-English speakers. I gather
that there's a fair number of French, German, Russian, Chinese and
Japanese C programmers, so it should be possible to find good texts in
any of those languages, but I can't tell you which ones. There's a lot
of Indian programmers out there, but as far as I can tell they all seem
to have bad things to say about the opportunities for learning
programming that were available to them in India. I'm not sure about any
other languages. I've no idea whether the standard is available in other
languages - as an International standard, it should be, but I can't
remember having ever heard of a translation into any other language.
- What should I learn in C to become a good programmer?

In the beginning, you'll be spending a lot of time learning how C works,
but that's just learning what the tools of your trade are. To become
good at programming, you need to know the best things to do with those
tools. I think that the most important things are good design and a
disciplined product development cycle. That's true for any programming
language, it isn't specific to C. A good developer will use C only for
tasks for which it's a good choice, and will adapt the design to take
into account the ways that C differs from other languages, but the most
basic principles of good design are pretty much language independent.
- Should I read the example C codes in the web?

Example code is useful only if you have good reason to believe it's well
written. Badly written C code can teach you a lot of bad habits, and
there's a lot more badly written C code out there, than well-written.
 
D

Dogukan Bayraktar

24 Nisan 2013 Çarşamba 23:00:51 UTC+3 tarihinde Jens Stuckelberger yazdı:
As a non-native English speaker myself I have to say that your

written English is not so bad; mine was certainly worse when I was 17. If

you can read English as you can write it you should be able to learn from

any standard textbook on C. Don't be afraid and try it. I am sure other

members of this forum, far more C-knowledgeable than me, will give you

relevant references.

Thanks for your comment :)
 
D

Dogukan Bayraktar

24 Nisan 2013 Çarşamba 23:35:58 UTC+3 tarihinde James Kuyper yazdı:
Trying for "perfect" is just setting yourself up for a lifetime of

disappointment. "good", on the other hand, is quite feasible. I

recommend trying to become an "expert" C programmer; it's an achievable

but challenging goal.







Finding a forum in your native language devoted to C programming would

be best. Depending upon what language that is, that might be difficult,

bordering on impossible. You might have to improve your English. My

wife's native language is Mandarin, and she's studying accounting. The

hardest part for her isn't the math, but the fact that all of the text

books are written in a very advanced, technically oriented dialect of

English. I suspect you'll have similar trouble with C if you can't find

good text books in your native language.






It shouldn't be - but as I'm a native speaker of English I wouldn't have

noticed if there are serious barriers for non-English speakers. I gather

that there's a fair number of French, German, Russian, Chinese and

Japanese C programmers, so it should be possible to find good texts in

any of those languages, but I can't tell you which ones. There's a lot

of Indian programmers out there, but as far as I can tell they all seem

to have bad things to say about the opportunities for learning

programming that were available to them in India. I'm not sure about any

other languages. I've no idea whether the standard is available in other

languages - as an International standard, it should be, but I can't

remember having ever heard of a translation into any other language.






In the beginning, you'll be spending a lot of time learning how C works,

but that's just learning what the tools of your trade are. To become

good at programming, you need to know the best things to do with those

tools. I think that the most important things are good design and a

disciplined product development cycle. That's true for any programming

language, it isn't specific to C. A good developer will use C only for

tasks for which it's a good choice, and will adapt the design to take

into account the ways that C differs from other languages, but the most

basic principles of good design are pretty much language independent.






Example code is useful only if you have good reason to believe it's well

written. Badly written C code can teach you a lot of bad habits, and

there's a lot more badly written C code out there, than well-written.

Thank you so much! I have learned a lot of things about English and C Programming :D

Your comment is so helpful for me..
~~ Thanks again :) ~~
 
K

Keith Thompson

Dogukan Bayraktar said:
Firstly, sorry for my bad English :/

It's certainly better than my anything-other-than-English.

Q: What do you call someone who speaks two languages?
A: Bilingual.
Q: What do you call someone who speaks only one language?
A: American.
I'm only 17 and I want to learn C and write perfect codes in C. I'm
not so good in C programming, but I want to become a good C
programmer.

My English is not enough to read the programming articles or anything.
What should I do to become a good C programmer?

- Do you think is English needed for programming?
- What should I learn in C to become a good programmer?
- Should I read the example C codes in the web?
- etc ... ?

One small piece of advice: if a book or tutorial tells you that

void main()

is correct, avoid it. It's not a huge deal by itself (many
compilers will accept it, and it's easy enough to change to the
correct "int main(void)" in your own code), but it's a sign that
the author really doesn't know the language very well.

("void main()" can actually be valid in some circumstances,
particularly for embedded systems, but you're not likely to be
using such systems.)
 
Ad

Advertisements

J

Johannes Bauer

"void main(void)" is preferable in most embedded systems - you want to
explicitly say it has no arguments. Of course, it's a different matter
if you intend to return from main or pass arguments to it, but in most
small embedded systems main() never exits.

"main" has a return parameter which is an int. Always.
Depending on the situation, I would say you are actually quite likely to
be working on embedded systems if you are programming in C. After all,
the great majority of embedded systems are coded in C (followed by C++),
and there are a great many embedded systems out there.

So because most embedded systems are programmed in C you conclude that
most C programms are for embedded systems? Something is seriously wrong
with your logic.

Regards,
Johannes

--
Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <[email protected]>
 
J

James Kuyper

"main" has a return parameter which is an int. Always.

He was responding to a comment Keith made that was specifically about
the fact (and it is a fact) that some compilers do accept void main(),
despite what it says to the contrary in the C standard.
So because most embedded systems are programmed in C you conclude that
most C programms are for embedded systems? Something is seriously wrong
with your logic.

Only because you left out a key step in that logic: "there are a great
many embedded systems out there". That's not enough to prove that most C
programs are for embedded systems, but depending upon the number
corresponding to "a great many", it could be strong supporting evidence
for that claim.

In this newsgroup I've talked with a number of people who thought that
most, if not all, current C programming is being done for embedded
platforms. When challenged, none have been able to provide hard numbers
in support of their claim. To be fair, I know of no good source of
numbers to disprove the claim, either. But the simple fact that anybody
believes it is, in itself, evidence for the existence of a fairly large
amount of embedded C programming going on.
 
S

Stephen Sprunk

It's certainly better than my anything-other-than-English.

Q: What do you call someone who speaks two languages?
A: Bilingual.
Q: What do you call someone who speaks only one language?
A: American.

American monolingualism is overstated; the commonly-cited statistic from
the Census Bureau tracks only languages spoken at home (18% not
English), not how many languages people are _capable_ of speaking.

One of the problems that English-speaking countries have is there is no
obvious choice of second language for our students, whereas English is
an obvious (and now by far the most common) choice in other countries.
There are only a handful of other languages spoken by enough people to
be useful, and these days most people in those countries are learning
English now, so why bother?

The main exception to that is for people who achieve fluency in two (or
more) languages, which enables a career as a translator or diplomat. In
the US, that is generally limited to second-generation immigrants
because our schools (a) start students on foreign languages too late and
(b) can't provide a critical mass of native speakers for them to
practice with.

Whether we like it or not, the programming world (and tech industry in
general) is dominated by English. If you don't know it at least well
enough to read articles, then working on that is essential, regardless
of which programming language you intend to use. User documentation and
interfaces are often localized, but systems and API documentation rarely
are.

On the plus side, you probably only need to learn to read and write
English, not speak it--though that would open up a huge number of job
opportunities for other reasons. I work with many programmers whose
accents are nearly incomprehensible to me, but their emails are clear
enough that it's not a barrier, and live conversations with them are
rare anyway due to time zone differences.

S
 
D

Dogukan Bayraktar

25 Nisan 2013 Perşembe 14:30:47 UTC+3 tarihinde David Brown yazdı:
English is not needed for programming - but it /is/ needed to be an

expert as will then have to read technical texts, standards, etc., as

well as work with existing source code and documentation from around the

world. Fair or not, English is the standard here. Even for programming

languages created and developed outside



But judging from your post here, your English is already better than

many adult native speakers, so don't worry about it. I'm sure there is

room for improvement, but that will come as you get more education, and

read and write more.



Incidentally, what is your native language?



As for becoming a good C programmer, the first question is /why/? If

you want to become a good programmer, C is not necessarily a good choice

for starting. The field of programming is vast - C is only suitable for

a small part of that. What sort of programming are you actually

interested in?

Thanks for you comment :)

I'm from Turkey. So my native language is Turkish. But I want to learn English so much :)

I've been learning C for 5 months. But I want to improve my skills for C programming. I love C/C++ languages more than other languages like Java and C#.

I'm interested in C/C++, Python, PHP.

I hope you understand me :)
 
R

Rui Maciel

Stephen said:
One of the problems that English-speaking countries have is there is no
obvious choice of second language for our students, whereas English is
an obvious (and now by far the most common) choice in other countries.
There are only a handful of other languages spoken by enough people to
be useful, and these days most people in those countries are learning
English now, so why bother?

From where I'm from, a foreign language (english) is included in the
national curriculum from the 1st grade, and a second foreign language from
the 7th grade onward.

For the second foreign language, students are free (technically*) to pick
from three available options -- german, french and spanish.

These choices are far from being "obvious", for a number of reasons. Yet,
people still choose and no one is harmed by it.

Regarding english-speaking countries, it can be argued that each one has its
glaring obvious choice.

- US: According to wikipedia[1], the country has 45 million people who speak
spanish as a first or second language. If we take into account that almost
all neighbouring countries to the south have spanish as their official
language, spanish does appear to be an obvious choice.
- Canada: it has two official languages: english and french.
- UK: even when ignoring their "regional" languages, the british isles do
have significant ties with France and Germany.

On top of that, if only less than 6% of the world are native english
speakers while over 14% speak Mandarin[2], in addition to China's increasing
prominence, Mandarin becomes a rather glaring choice.

Therefore, there are no obvious choices only to those who never bothered to
think about it.


Rui Maciel

[1] http://en.wikipedia.org/wiki/Spanish_language_in_the_United_States
[2]
http://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers
 
Ad

Advertisements

O

osmium

Rui Maciel said:
On top of that, if only less than 6% of the world are native english
speakers while over 14% speak Mandarin[2], in addition to China's
increasing
prominence, Mandarin becomes a rather glaring choice.

Therefore, there are no obvious choices only to those who never bothered
to
think about it.

As I understand it, your obvious choice is Mandarin. ISTM your reasoning is
valid for someone from outer space expecting to land at some random spot on
the earth of this planet. It loses a lot of its' obviousness when you
factor in the practicalities of already being an earth dweller. So far I
don't think I have *ever* encountered a Chinese peasant - or whatever they
call them nowadays.

A good friend of mine is Indian; he had to learn a new language to go to
University. He told me the only thing the Indian people have in common is
black hair.
 
J

Johannes Bauer

No, "main" does not always have a return parameter

Well, if the code conforms to the C standard, it should return int.
- "main" does not
always return, and therefore a return parameter is meaningless.

It's mandated by the C standard. So if you want to have a standard
compliant program, it is very meaningful. Not in a way that transports
any information (because the return value itself may be discarded).
In most
(small) embedded systems, main() never exits.

I disagree completely. Is a 4 bit microcontroller small enoguh to
qualify as "small"? Because these are the smallest I've programmed (in
C). And nowhere, ever, have I encountered an environment that has no
main somewhere (sure, maybe hidden from the application developer, but
it is indeed there when you look for it).
Including a return
parameter may mean wasted code, and will mean your compiler and/or
static code checker will warn about unreachable code (if you include a
return value) or missing return values (if you don't).

Any smart compiler will optimize that away. And standard compliance is
more important than that one instruction (even on a 8 bit MCU!) that
sets the return value.
Is such a "void main(void)" declaration valid according to the strictest
C conformance? Perhaps not - but then, most (probably all) embedded
compilers and embedded programs are non-conforming in at least a few
small ways. They often have C libraries with limitations, floating
point implementations that are not fully IEEE, extra keywords for
special memory handling, etc.

Actually, many deeply embedded systems have no floating point support at
all (because the sheer soft-float library is so large that it would
completely fill the ROM. I'm actually not sure if float support is
required by the standard, but would guess that it might be the case.
I also found this reference:
<http://c0x.coding-guidelines.com/5.1.2.2.1.html>

I don't know whether this is from an official standards document, but
point 167 clearly says that "main" can be defined "in some other
implemention-defined manner".

Hm, interesting. Would be interesting to know what is meant by that.
Because "implementation-defined manner" can also mean that nothing
(neither the prototype nor the name 'main' itself is required).
Do I think that most C programs are written for embedded systems? No, I
don't - that's why I did not say so.

Gotcha. Misunderstood you there, sorry about that.
But if someone tells me he wants to learn to program and asks what
language to use, I would only say "C" if it was for embedded systems.
If someone asks me what language is appropriate for a given project,
then the answer is seldom "C" - unless it is an embedded system, a very
low-level program, a high-speed library, or a very time-critical program
(even then C is often not the best choice).

I agree.
I think this difference is particularly apparent in newer, younger
programmers. There was a time when people used C for everything from
small scripts or utilities to large applications - and people who are
used to that, continue to do so. But for a new developer, you would be
better off with Python, Java, Ruby, C++, etc.

Couldn't agree more.
Of course, being good at C programming is an essential skill for /any/
expert programmer, even if you do most of your work in other languages.
It's like having a good understanding of assembly is essential for
being an expert C programmer, especially on embedded systems.

Couldn't agree more here as well.

Best regards,
Johannes

--
Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <[email protected]>
 
J

James Kuyper

On 04/25/2013 12:00 PM, David Brown wrote:
....
Is such a "void main(void)" declaration valid according to the strictest
C conformance? Perhaps not - but then, most (probably all) embedded
compilers and embedded programs are non-conforming in at least a few
small ways. They often have C libraries with limitations, floating
point implementations that are not fully IEEE, extra keywords for
special memory handling, etc.

The C standard doesn't require IEEE conformance. Even if the
implementation pre#defines __STDC_IEC_60559__, that doesn't require full
conformance with IEC 60559 (== IEEE 754). It only requires conformance
with Annex F. Annex F cross-references a large part of IEC 60559, but
not all of it.

Extra keywords are also not a problem, so long as care is taken to
ensure that they are from the name space reserved to the implementation.
I also found this reference:
<http://c0x.coding-guidelines.com/5.1.2.2.1.html>

I don't know whether this is from an official standards document, but

According to <http://c0x.coding-guidelines.com/>, the citations are from
N1256.pdf. That's an unofficial committee draft based upon four official
documents: the C99 standard and three Technical Corrigenda, which were
written as corrections to C99 itself. n1256.pdf combines those
documents, applying the specified corrections to C99, something that has
not been done in any official version of the standard. As a result, it's
actually more useful than any official version of C99. If there's a
discrepancy between what n1256.pdf says and what the official documents
say, then it's the official ones that are correct, but as far as I know,
there's only one such discrepancy known, and it's a rather obscure one.
The only other error it's known to possess is that on every single page
of the document, the date on which the document was completed has
"September" misspelled as "Septermber".
point 167 clearly says that "main" can be defined "in some other
implemention-defined manner".

It can, but what 5.1.2.2.1 says is "It shall be defined with a return
type of int and [details of one permitted form] or [details of a second
permitted form] or equivalent; or in some other implementation-defined
manner."

It has been argued that "A and B or C or D; or E" should be parsed as
"(A and B) or C or D; or E", but that doesn't make sense. The intended
parse was "A and (B or C or D; or E)" (I'm not sure what affect the ';'
should have on the parse). If that weren't the case, A (== "it shall be
defined with a return type of int") would be redundant, since the two
explicitly specified forms already give a return type of 'int'. If that
clause wasn't intended to apply to the "other implementation-defined
manner", it could simply have been dropped.
 
J

James Dow Allen

("void main()" can actually be valid in some circumstances,
particularly for embedded systems, but you're not likely to be
using such systems.)

I click on c.l.c every now and then just to see
if any interesting code snippets are posted.
(Or to see if any of the worst pedants ever
get enlightenment.)
A straightforward general question is asked here
.... and almost half the posts deal with the pressing
issue:
To void main or not to void; that is the question.

Wow. Just ... Wow!
Perhaps the best immediate advice to Dogukan
will be to explain killfiles.

James
 
J

James Kuyper

Well, if the code conforms to the C standard, it should return int.

No, that's not actually required. The standard's definition of a
"conforming program" was determined by politics, not technical
considerations. It's so broad that the only feature a program could
possess that would render it non-conforming is a correctly (sic!)
formatted #error directive that survives conditional compilation. The
book of Genesis (in the original Hebrew!) is a conforming C program,
since it doesn't contain any of the characters needed to write #error.

"strict conformance" is a different matter. A strictly conforming C
program must indeed use a declaration for main() that is equivalent to
one of the two methods given explicitly in 5.1.2.2.1. It's
implementation-defined whether any other forms are supported, and
strictly conforming code is not allowed to depend upon
implementation-defined features.
Actually, many deeply embedded systems have no floating point support at
all (because the sheer soft-float library is so large that it would
completely fill the ROM. I'm actually not sure if float support is
required by the standard, but would guess that it might be the case.

Support for floating point math is required. However, library support of
floating point is optional for freestanding implementations of C.
 
Ad

Advertisements

R

Rui Maciel

osmium said:
As I understand it, your obvious choice is Mandarin.

To some, it is. I know of a university whose student body offers paid
Mandarin classes.

ISTM your reasoning
is valid for someone from outer space expecting to land at some random
spot on the earth of this planet. It loses a lot of its' obviousness when
you factor in the practicalities of already being an earth dweller.

I can only speak from personal experience. English is not my native
language, and when I was growing up odds were that for the average joe
understanding it was only useful if you really wanted to know what pop
singers were blabbering about. In practical terms, people were better off
learning french or german. Then the internet happened, and English became
the de facto Esperanto.

But this is the past.

Considering that the world's economy is steadily migrating to China in
particular and Asia in general, not to mention the amount of academic
production, its highly probable that knowing Mandarin will end up being a
required skill. I know people who already invested in learning it and
proudly advertise it on their CV.


Rui Maciel
 
K

Keith Thompson

Johannes Bauer said:
"main" has a return parameter which is an int. Always.

That's incorrect.

Here's what the standard says about the main function for a conforming
hosted implementation:

It shall be defined with a return type of int and with no parameters:

int main(void) { /* ... */ }

or with two parameters (referred to here as argc and argv,
though any names may be used, as they are local to the function
in which they are declared):

int main(int argc, char *argv[]) { /* ... */ }

or equivalent; or in some other implementation-defined manner.

The phrase "implementation-defined" means that the implementation must
document it.

So if your compiler's documentation says you can define

void main(void) { /* ... */ }

then you can do that, and your program is conforming *for that
implementation*. And if it doesn't, then your program violates a
"shall" that appears outside a constraint, which means that its
behavior is undefined -- which means that it *can* behave just as
if you had defined it with a return type of int.

But for a hosted implementation, there's very little *reason* to define
main as a void function. And if you're writing a book about C,
suggesting that "void main" is valid for hosted implementations without
explaining how and why it might not be valid is malpractice.

Also quoting the standard:

In a freestanding environment (in which C program execution
may take place without any benefit of an operating system),
the name and type of the function called at program startup
are implementation-defined.

Depending on the choices made by the authors of the implementation,
the entry point might be "void main(void)", or it might be "double
foobar(double complex*)". "int main(void)" might even be invalid
in such an environment.
So because most embedded systems are programmed in C you conclude that
most C programms are for embedded systems? Something is seriously wrong
with your logic.

You're assuming, among other things, that his conclusion follows only
from those other statements. And he didn't say that *most* C programs
are for embedded systems, only that "you are actually quite likely to be
working on embedded systems if you are programming in C" ("quite likely"
needn't imply more than 50%).

I suspect, without proof, that his conclusion is correct. (I work on
embedded systems myself, but they're embedded systems with an OS.)

In any case, I think that most *introductory* C tutorials are likely to
deal with hosted implementations such as Linux, MacOS, or Windows.
 
Ad

Advertisements

K

Keith Thompson

James Kuyper said:
He was responding to a comment Keith made that was specifically about
the fact (and it is a fact) that some compilers do accept void main(),
despite what it says to the contrary in the C standard.
[...]

Actually the C standard doesn't say anything to the contrary. Though it
doesn't mention "void main" explicitly, the form of a program's entry
point can be implementation-defined for hosted implementations, and is
*always* implementation-defined for freestanding implementations.
 

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

Top