Jack Klein said:
Wait a minute I think I might've just caught my problem. It's in the
function body where I'm making the error. Not assigning name[] to
anything
in the body. What about this.
char passw(char name[])
{char i=name;
....
if (strcmp(i,name2)==0) {printf"ok");}
else if(strcmp(i,name2)!0) {puts("unequal rtry again");
return
passw();}
'char *s=name;', would be ok.
'char i=name;' has 2 problems:
'char i;' is an integer type, not a string;
via common practice/tradition, many names have certain reserved meanings
and
usages, and you have just violated one of the major ones...
The C standard spells out certain name spaces for identifiers that are
reserved for the implementation in various circumstances. The OP's
code did not use any of these reserved names. He has violated
nothing.
Nothing but the C standard specifies reserved identifiers in C.
<snip>
http://en.wikipedia.org/wiki/Coding_conventions
To about repetition, let's define a short-hand notation. When "says
nothing to support your assertion" appears in the text below, please
expand it in your mind to the phrase "says nothing at all about
single-letter variable names, or about names beginning with certain
letters being in any way associated with specific data types."
This wikipedia article says nothing.
Of the 8 links in the "references" section, one of them mentions C++
and says nothing to support your assertion. Another, which does not
specify language, pulls up an indication from the host site that the
page name is invalid.
It does link to another wikipedia page:
http://en.wikipedia.org/wiki/Naming_conventions_(programming)
....which says nothing on your assertion.
or, as an example of a fairly well-known convention system:
http://en.wikipedia.org/wiki/Hungarian_notation
Few things are more discredited than Hungarian notation, even
Microsoft has abandoned it. Article ignored.
This is later, and less obnoxious, than earlier versions of the Indian
Hills guide I remember seeing in the past, but it says nothing to
support your assertion.
This page has links to about a dozen or so coding standards, one for C
and many others for C++. It also has an illegal copy of the actual
ISO C++ 1998 and standard, and a copy of a draft of C99 TC2, off-hand
I am not sure of the legality of that.
I looked at three of the linked coding standards, Stroustrup, Stallman
(the only one for C), and Hoff. None of them support your assertion.
they are generally viewed as programmer or self-imposed conventions.
the standards as such, don't care.
neither do compilers.
however, none the less, there are common practices, and one is ill-advised
Common to whom, other than yourself?
to so blatently violate them, as the OP has done. to do so, leads to ugly,
unmaintainable, and incomprehensible code.
and, if one reads lots of code by lots of people, one will see that there
are many common, specific, and generally informally enforced conventions.
one violates them at their own risk...
I have not spent the time, nor will I, tracking down every linked
document that might be relevant from the direct URLs that you
presented. In a modest sample, I found not one such document for
either C or C++ that suggests the use of single-letter identifiers at
all, or suggests that specific single-character identifiers, or
identifiers starting with specific letters, be reserved for specific
types.
So I put it to you:
Can you provide a direct link to one or more documents about coding
standards in C that make the claim that identifiers 'i', 'j', and 'k',
or even identifiers starting with those letters, should be used only
or even primarily for integer variables?
I will not add the requirement for "well known" or "well respected"
sources, because they are subjective and you can't know what sources I
would consider to meet those criteria.
So can you provide any direct link at all to any coding standards
documents for C, from any source, that recommends reserving
identifiers beginning with those three letters for integer type
variables? IN C.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html