[A89] Re: A problem


[Prev][Next][Index][Thread]

[A89] Re: A problem




> ok, i did it like this:
>
> int starte(char fn[])
> {
>          ...
> }
>
> void main(void)
> {
>          char map[9]="map";
>          ...
>          check=starte(map);
>          ...
> }
>
> and it worked, now to change char fn[] to char *fn, i also needed to
change
> the char map[9]="map" to char map[9]="map\0", so what you are saying is
> that the first way i did it, it overwrote a byte somewhere in the program?

No; if all you do is change this line:
    int starte(char fn[])
to this:
    int starte(char* const fn)
then it should work just fine.  If that doesn't, then something is very
wrong =)

By the way, it doesn't look like you're not prototyping your functions.
I've seen that trend among a lot of new C programmers, and most experienced
programmers (as well as every book I've ever seen) will tell you that it's
very, very, very bad not to prototype functions.  It may not seem like it
makes sense now, but their use becomes apparent as your programs get more
complex (particularly in C++).

Apparently many people are learning from web resources, but you have to be
very careful when doing so.  Books aren't going to be published if they're
bad or wrong; but I saw piss-poor C sites online all the time when trying to
learn the language myself.  I chose to buy some books instead, and heartily
advise _C for Dummies_ for those who are new to programming, and _The C
Programming Language_ (by Kernighan and Ritchie) for programmers with some
prior experience.  Books are still the way to go, IMHO.

> And thanks for putting up with all these questions. I should know them,
but
> my education is a lil haphazard.

I don't mind them at all -- actually, I _enjoy_ answering many of these
questions (until somebody tells me I'm wrong, that is =)  And many of these
things aren't usually found in your standard books and resources; those are
good for the basics, but afterwards I've found that interaction with others
is the best way to learn.

I only get pissed when complete newbies ask questions which show they've
made no decent attempt to find the answer themselves.  I can't think of any
good example of that right now, but they pop up on this list every once in a
while =)

    -Scott





Follow-Ups: