Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ike Naar <ike@sdf.lonestar.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Is there a shorter solution ? |
| Date | 2011-08-06 17:42 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrn3vfsj3qv8q.234.ike@sdf.lonestar.org> (permalink) |
| References | <f5a3d4b3-e101-44c1-921d-6c546b1e2f78@d7g2000vbv.googlegroups.com> |
On 2011-08-06, HumbleWorker <amardeep.developer@gmail.com> wrote:
> Count the number of a in cX below
>
> #include <stdio.h>
>
> int main()
> {
> char cX[] = "ababcabcdabcaba", * k = cX;
> int numA = 0;
>
> while (*k && ('a' == *k++ ? ++numA : 1));
>
> printf ("Number of a's = %u\n", numA);
The ``%u'' format expects an unsigned int, you're supplying a signed int.
Don't do that.
Either use ``int numA'' with ``%d'', or ``unsigned int numA'' with ``%u''.
>
> return 0;
> }
--
ike@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is there a shorter solution ? HumbleWorker <amardeep.developer@gmail.com> - 2011-08-06 10:25 -0700
Re: Is there a shorter solution ? Ike Naar <ike@sdf.lonestar.org> - 2011-08-06 17:42 +0000
Re: Is there a shorter solution ? John Gordon <gordon@panix.com> - 2011-08-06 17:44 +0000
Re: Is there a shorter solution ? Kenneth Brody <kenbrody@spamcop.net> - 2011-08-08 09:47 -0400
Re: Is there a shorter solution ? Keith Thompson <kst-u@mib.org> - 2011-08-08 08:09 -0700
Re: Is there a shorter solution ? HumbleWorker <amardeep.developer@gmail.com> - 2011-08-10 07:20 -0700
Re: Is there a shorter solution ? tom st denis <tom@iahu.ca> - 2011-08-10 09:43 -0700
Re: Is there a shorter solution ? HumbleWorker <amardeep.developer@gmail.com> - 2011-08-10 09:51 -0700
Re: Is there a shorter solution ? James Kuyper <jameskuyper@verizon.net> - 2011-08-10 12:57 -0400
Re: Is there a shorter solution ? HumbleWorker <amardeep.developer@gmail.com> - 2011-08-10 10:13 -0700
Re: Is there a shorter solution ? blp@cs.stanford.edu (Ben Pfaff) - 2011-08-10 10:17 -0700
Re: Is there a shorter solution ? HumbleWorker <amardeep.developer@gmail.com> - 2011-08-10 10:29 -0700
Re: Is there a shorter solution ? tom st denis <tom@iahu.ca> - 2011-08-10 11:29 -0700
Re: Is there a shorter solution ? "J. J. Farrell" <jjf@bcs.org.uk> - 2011-08-11 03:02 +0100
Re: Is there a shorter solution ? Kenneth Brody <kenbrody@spamcop.net> - 2011-08-12 11:39 -0400
Re: Is there a shorter solution ? Keith Thompson <kst-u@mib.org> - 2011-08-12 09:06 -0700
Re: Is there a shorter solution ? James Kuyper <jameskuyper@verizon.net> - 2011-08-10 14:00 -0400
Re: Is there a shorter solution ? Seebs <usenet-nospam@seebs.net> - 2011-08-11 01:46 +0000
Re: Is there a shorter solution ? Keith Thompson <kst-u@mib.org> - 2011-08-10 11:49 -0700
Re: Is there a shorter solution ? James Kuyper <jameskuyper@verizon.net> - 2011-08-10 15:03 -0400
Re: Is there a shorter solution ? Keith Thompson <kst-u@mib.org> - 2011-08-10 13:23 -0700
Re: Is there a shorter solution ? gordonb.d3r7p@burditt.org (Gordon Burditt) - 2011-08-10 18:15 -0500
Re: Is there a shorter solution ? HumbleWorker <amardeep.developer@gmail.com> - 2011-08-10 11:26 -0700
Re: Is there a shorter solution ? James Kuyper <jameskuyper@verizon.net> - 2011-08-10 15:14 -0400
csiph-web