From: jshiffer@zerotao.org (Jason L. Shiffer)
To: linux-c-programming@vger.kernel.org
Subject: Re: Problem with "chars"
Date: Wed, 17 Jul 2002 09:30:41 -0400 [thread overview]
Message-ID: <20020717133041.GA13442@zerotao.org> (raw)
In-Reply-To: <20020717040816.A54117@nietzsche.metrotel.net.co>
On Wed, Jul 17, 2002 at 04:08:16AM -0500, xlp wrote:
> I dont understand what's the way I should handle 'chars' on C.
> I need to code a C function that returns a char, I want to do this:
> char foo();
> main(){
> char bar*;
> bar=foo();
> }
Firstly if you are just going to return a char ie. some value between
-128 & 127, then the above definition is incorrect:
char bar*; defines a char pointer most commenly known as a string;
char bar; defines a char
> How should i declare the 'char' inside foo()?
the same as above eg,
char foo(void){
char x = 'a';
return x;
}
> How should i 'return' the char inside foo()?
see the previous example.
> How can i understand "chars" and pointers to chars?, I have a C books, but I dont get it, because ALL THE EXAMPLES are with chars like char foo[20], that is the easy way!, I want to handle char without a specific length!.
The best book that I know of for this is "Expert C Programming (Deep C
Secrets) ISBN:0-13-177429-8. And don't let the name scare it is a great
book that will take you pretty much from entry level programming to
advanced topics.
As a short introduction you can think about pointers like this:
char a = 'b'; //the symbol a represents the VALUE b
char *b = &a; //the symbol b represents the MEMORY ADDRESS of the
//symbol a;
it is a little simplified but I hope that it helps.
Jason
>
> bye.
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2002-07-17 13:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-17 9:08 Problem with "chars" xlp
2002-07-17 13:30 ` Jason L. Shiffer [this message]
2002-07-17 14:19 ` Elias Athanasopoulos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020717133041.GA13442@zerotao.org \
--to=jshiffer@zerotao.org \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).