473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

q3b

Mark,

I don't know how to do this with spaces or for. So I will post another way
of doing it and I don't know how to include spaces. But the program works.

Bill

#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
printf("%s\n",a);
}
Jul 27 '08 #1
28 1485
"Bill Cunningham" <no****@nspam.comwrites:
Mark,

I don't know how to do this with spaces or for. So I will post another way
of doing it and I don't know how to include spaces. But the program
works.
You were unlucky. I have more luck, it seems. On my system I get:

0123456�-��H.��Pt���l��ЃH.��Pt��

Do you know why?
#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
I am surprised that:

char a[]={'0',' ','1',' ','2',' ','3',' ','4',' ','5',' ','6'};

did not occur to you. Knowing why you did not think of it is probably
more helpful than getting the program right. For example, did you
look for, and not find, a special escape sequence for a space
character (like there is for newline: '\n'). If so what did you do
when you did not find it? Maybe you simply did not know how to write
a space and you don't know any way to find such things out. I have a
feeling that examining these questions will be more helpful to you
than someone telling you how to write a space.
printf("%s\n",a);
}
--
Ben.
Jul 27 '08 #2

"Ben Bacarisse" <be********@bsb.me.ukwrote in message
news:87************@bsb.me.uk...
I am surprised that:

char a[]={'0',' ','1',' ','2',' ','3',' ','4',' ','5',' ','6'};

Actually it did enter my mind but I figured some strange code would occur.
did not occur to you. Knowing why you did not think of it is probably
more helpful than getting the program right. For example, did you
look for, and not find, a special escape sequence for a space
character (like there is for newline: '\n'). If so what did you do
when you did not find it? Maybe you simply did not know how to write
a space and you don't know any way to find such things out. I have a
feeling that examining these questions will be more helpful to you
than someone telling you how to write a space.
> printf("%s\n",a);
}

--
Ben.

Jul 27 '08 #3
Ben Bacarisse wrote:
"Bill Cunningham" <no****@nspam.comwrites:
> Mark,

I don't know how to do this with spaces or for. So I will post
another way of doing it and I don't know how to include
spaces. But the program works.
You were unlucky. I have more luck, it seems. On my system I
get:

0123456�-��H.��Pt���l��ЃH.��Pt��

Do you know why?
Think "Zero terminated string".

char a[]={'0','1','2','3','4','5','6', '\0'};

or

char a[]={'0','1','2','3','4','5','6', 0}; /* mind the missing
single quotes here */

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber.org, ICQ: 134682867

Jul 27 '08 #4
Wolfgang Draxinger <wd********@darkstargames.dewrites:
Ben Bacarisse wrote:
>"Bill Cunningham" <no****@nspam.comwrites:
>> Mark,

I don't know how to do this with spaces or for. So I will post
another way of doing it and I don't know how to include
spaces. But the program works.

You were unlucky. I have more luck, it seems. On my system I
get:

0123456�-��H.��Pt���l��ЃH.��Pt��

Do you know why?

Think "Zero terminated string".
Well, I knew that...
char a[]={'0','1','2','3','4','5','6', '\0'};
Oh, well, so much for hoping Bill will work it out!

--
Ben.
Jul 27 '08 #5
"Bill Cunningham" <no****@nspam.comwrites:
I don't know how to do this with spaces or for. So I will post another way
of doing it and I don't know how to include spaces. But the program works.

Bill

#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
printf("%s\n",a);
}
No, it doesn't "work". It doesn't satisfy the stated requirements.

Here's another program that doesn't satisfy the stated requirements:

int main(void) { return 0; }

It "works" too.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 28 '08 #6
On Sun, 27 Jul 2008 17:45:23 GMT, "Bill Cunningham" <no****@nspam.com>
wrote:
Mark,

I don't know how to do this with spaces or for. So I will post another way
of doing it and I don't know how to include spaces. But the program works.

Bill

#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
printf("%s\n",a);
}
The only thing this program does is invoke undefined behavior. Since
you started a new thread, haven't told us what the program is supposed
to do, but do claim it works, I will give you the benefit of the doubt
and wonder why you are writing programs specifically to invoke
undefined behavior.
Remove del for email
Jul 28 '08 #7
Barry Schwarz <sc******@dqel.comwrites:
On Sun, 27 Jul 2008 17:45:23 GMT, "Bill Cunningham" <no****@nspam.com>
wrote:
> Mark,

I don't know how to do this with spaces or for. So I will post another way
of doing it and I don't know how to include spaces. But the program works.

Bill

#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
printf("%s\n",a);
}

The only thing this program does is invoke undefined behavior. Since
you started a new thread, haven't told us what the program is supposed
to do, but do claim it works, I will give you the benefit of the doubt
and wonder why you are writing programs specifically to invoke
undefined behavior.
If you are going to confuse an obviously already confused person like
Bill with such a damning of his work, do you not think it might be a nice
idea to describe WHY you think his program produces undefined behaviour?
>

Remove del for email
(It might be nice if your put this below a .sig delimiter)
Jul 28 '08 #8
On Mon, 28 Jul 2008 05:47:33 +0200, Richard<rg****@gmail.comwrote:
>Barry Schwarz <sc******@dqel.comwrites:
snip
>>
Remove del for email

(It might be nice if your put this below a .sig delimiter)
I have tried to add a line -- \n before the demunging instructions.
Does it serve as the proper delimiter?

--
Remove del for email
Jul 28 '08 #9
Barry Schwarz said:
On Mon, 28 Jul 2008 05:47:33 +0200, Richard<rg****@gmail.comwrote:
>>Barry Schwarz <sc******@dqel.comwrites:
snip
>>>
Remove del for email

(It might be nice if your put this below a .sig delimiter)

I have tried to add a line -- \n before the demunging instructions.
Does it serve as the proper delimiter?
Yes. Good chap.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 28 '08 #10
Ben Bacarisse wrote:
Oh, well, so much for hoping Bill will work it out!
Well, some people just need direct awnsers to learn things. I
hated it, then in math classes (university) we just got a bunch
of exercises "to work them out", and everytime you asked some
question out of curiousity all you got as an awnser were hints
in which direction, and which book the solution might be.

Why not just tell, how things are? This gives the person who asks
the possibility to think a few seconds about it and maybe ask
the next question, based on new insight due to the first awnser.

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber.org, ICQ: 134682867

Jul 28 '08 #11
On Jul 28, 4:16 am, Wolfgang Draxinger <wdraxin...@darkstargames.de>
wrote:
Ben Bacarisse wrote:
Oh, well, so much for hoping Bill will work it out!
Bill _can_ work it out, but he doesn't show it because he's a troll.
Well, some people just need direct awnsers to learn things. I
I thought this was a typo, but since you repeated it, it's "answer".
hated it, then in math classes (university) we just got a bunch
of exercises "to work them out", and everytime you asked some
question out of curiousity all you got as an awnser were hints
in which direction, and which book the solution might be.

Why not just tell, how things are? This gives the person who asks
the possibility to think a few seconds about it and maybe ask
the next question, based on new insight due to the first awnser.
"Give a man a fish; you have fed him for today. Teach a man to fish;
and you have fed him for a lifetime".

Which pretty much means that if one gives you the answer directly,
you'll seek answers from him. If one teaches you to find the answers,
you won't need anyone else but yourself.
Jul 28 '08 #12
vi******@gmail.com wrote:
I thought this was a typo, but since you repeated it, it's
"answer".
Not again... This is the word I keep to misspell constantly.

answer, answer, answer, answer, ans... WTH:
for(int i=0; i<100; ++i) printf("answer, ");
"Give a man a fish; you have fed him for today. Teach a man to
fish; and you have fed him for a lifetime".

Which pretty much means that if one gives you the answer
directly, you'll seek answers from him. If one teaches you to
find the answers, you won't need anyone else but yourself.
Give a man a fish and he might get the idea, where to get food
from.

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber.org, ICQ: 134682867

Jul 28 '08 #13
On Jul 28, 10:35 pm, Wolfgang Draxinger <wdraxin...@darkstargames.de>
wrote:
vipps...@gmail.com wrote:
"Give a man a fish; you have fed him for today. Teach a man to
fish; and you have fed him for a lifetime".
Which pretty much means that if one gives you the answer
directly, you'll seek answers from him. If one teaches you to
find the answers, you won't need anyone else but yourself.

Give a man a fish and he might get the idea, where to get food
from.
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.
Jul 29 '08 #14
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.
Not necessarily. A man has only been eating 'chicken of the sea' (that's
canned, processed tuna).

If CotS suddenly stops producing, And you hand him a fishing pole and a net,
he's going to look at you funny.
That's what some people seem to thing is teaching a man to fish. Even if you
hand the guy a few tuna, and say 'you can use the pole and net to get them
from over in the ocean', he'll still look at you funny because he doesn't
have the context, he doesn't have the context to know those little fish can
be ground up to make his (revolting) culinary delight.

Yes, don't give the man a fish, teach him to fish. However, try to find what
context he has so you know what to teach him, rather than just showing some
little bit of stuff, which is likely as not, going to confuse him.

And when you hand him the pole when he's wondering how to get food, don't
say "betcha didn't think about using one of these, did ya?" Of course not.
He didn't have the context. Think about (or ask) /why/, otherwise you aren't
helping the person learn any more than you would just handing him a fish,
but instead of helping him in the short term, you are hurting him in the
short and long term.
Jul 29 '08 #15
On Jul 29, 4:33 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.

Not necessarily. A man has only been eating 'chicken of the sea' (that's
canned, processed tuna).
<snip>

Who are you talking to?
Jul 29 '08 #16
In article <31**********************************@m73g2000hsh. googlegroups.com>,
<vi******@gmail.comwrote:
>On Jul 29, 4:33 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.

Not necessarily. A man has only been eating 'chicken of the sea' (that's
canned, processed tuna).

<snip>

Who are you talking to?
I would assume, to the whole group, Keith.

(and/or, one might say, to the "regs" in particular)

Jul 29 '08 #17

<vi******@gmail.comwrote in message
news:31**********************************@m73g2000 hsh.googlegroups.com...
On Jul 29, 4:33 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.

Not necessarily. A man has only been eating 'chicken of the sea' (that's
canned, processed tuna).

<snip>

Who are you talking to?
You, I was extending the 'teach a man to fish' analogy, in regards to the
situation as I saw it. That line was setup for the analogy.
Jul 29 '08 #18
On Jul 29, 6:32 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
<vipps...@gmail.comwrote in message

news:31**********************************@m73g2000 hsh.googlegroups.com...
On Jul 29, 4:33 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.
Not necessarily. A man has only been eating 'chicken of the sea' (that's
canned, processed tuna).
<snip>
Who are you talking to?

You, I was extending the 'teach a man to fish' analogy, in regards to the
situation as I saw it. That line was setup for the analogy.

Then please leave the attributes untouched :-)
Jul 29 '08 #19
vi******@gmail.com wrote:
On Jul 29, 6:32 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
><vipps...@gmail.comwrote in message

news:31**********************************@m73g2000 hsh.googlegroups.com...
>>
On Jul 29, 4:33 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.
>Not necessarily. A man has only been eating 'chicken of the sea'
(that's canned, processed tuna).
<snip>
Who are you talking to?

You, I was extending the 'teach a man to fish' analogy, in regards to
the situation as I saw it. That line was setup for the analogy.


Then please leave the attributes untouched :-)
Maybe news clients should const qualify them. :-)

Jul 29 '08 #20

<vi******@gmail.comwrote in message
news:b6**********************************@56g2000h sm.googlegroups.com...
On Jul 29, 6:32 pm, "S James S Stapleton" <stapleton...@osu.edu>
>You, I was extending the 'teach a man to fish' analogy, in regards to the
situation as I saw it. That line was setup for the analogy.


Then please leave the attributes untouched :-)
I apologize. Unfortunately a common mistake of mine, it's only recently been
brought to my attention, and I'm still working on getting better.
Jul 29 '08 #21
<vi******@gmail.comwrote in message
news:4b**********************************@m3g2000h sc.googlegroups.com...
On Jul 28, 10:35 pm, Wolfgang Draxinger <wdraxin...@darkstargames.de>
wrote:
>vipps...@gmail.com wrote:
"Give a man a fish; you have fed him for today. Teach a man to
fish; and you have fed him for a lifetime".
Which pretty much means that if one gives you the answer
directly, you'll seek answers from him. If one teaches you to
find the answers, you won't need anyone else but yourself.

Give a man a fish and he might get the idea, where to get food
from.

Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.
Give a man a fish, and this could happen:
http://www.youtube.com/watch?v=WsfiD78Cy0s

** Posted from http://www.teranews.com **
Jul 29 '08 #22
In article <31**********************************@m73g2000hsh. googlegroups.com>,
<vi******@gmail.comwrote:
>On Jul 29, 4:33 pm, "S James S Stapleton" <stapleton...@osu.edu>
wrote:
Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.

Not necessarily. A man has only been eating 'chicken of the sea' (that's
canned, processed tuna).

<snip>

Who are you talking to?
Charlie the Tuna.
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 29 '08 #23
S James S Stapleton wrote:
>
>Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.
.... snip ...
>
If CotS suddenly stops producing, And you hand him a fishing pole
and a net, he's going to look at you funny. That's what some
people seem to thing is teaching a man to fish. Even if you hand
the guy a few tuna, and say 'you can use the pole and net to get
? them from over in the ocean', he'll still look at you funny
because he doesn't have the context, he doesn't have the context
to know those little fish can be ground up to make his (revolting)
culinary delight.
You haven't met many of 'those little fish', have you? :-)

Please don't strip attribution lines for quoted material when you
post. Those are the initial lines of the form "Joe wrote:".

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Jul 29 '08 #24
vi******@gmail.com wrote:
"S James S Stapleton" <stapleton...@osu.eduwrote:
>>Yeah, the idea he'll get is to get the food from _you_, not from
fishing. I hope you do see my point now.

Not necessarily. A man has only been eating 'chicken of the sea'
(that's canned, processed tuna).

<snip>

Who are you talking to?
The world. Usenet is not e-mail, everything is public.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Jul 29 '08 #25
CBFalconer wrote:
vi******@gmail.com wrote:
"S James S Stapleton" <stapleton...@osu.eduwrote:
>Yeah, the idea he'll get is to get the food from you, not from
fishing. I hope you do see my point now.
>
Not necessarily. A man has only been eating 'chicken of the sea'
(that's canned, processed tuna).
<snip>

Who are you talking to?

The world. Usenet is not e-mail, everything is public.
I believe the reference was to the fact that the reply had stripped all
attributions.


Brian
Jul 29 '08 #26
"Default User" <de***********@yahoo.comwrites:
CBFalconer wrote:
>vi******@gmail.com wrote:
"S James S Stapleton" <stapleton...@osu.eduwrote:

Yeah, the idea he'll get is to get the food from you, not from
fishing. I hope you do see my point now.

Not necessarily. A man has only been eating 'chicken of the sea'
(that's canned, processed tuna).

<snip>

Who are you talking to?

The world. Usenet is not e-mail, everything is public.

I believe the reference was to the fact that the reply had stripped all
attributions.


Brian
Someone should digest and publish all your and CBF's advice to this
group Bwian. You bring advanced C to the masses with each and every
post.
Jul 30 '08 #27
In article <g6**********@registered.motzarella.org>,
Richard <rg****@gmail.comwrote:
....
>Someone should digest and publish all your and CBF's advice to this
group Bwian. You bring advanced C to the masses with each and every
post.
Careful now. They're likely to take that as a compliment.

Jul 30 '08 #28
ga*****@xmission.xmission.com (Kenny McCormack) writes:
In article <g6**********@registered.motzarella.org>,
Richard <rg****@gmail.comwrote:
...
>>Someone should digest and publish all your and CBF's advice to this
group Bwian. You bring advanced C to the masses with each and every
post.

Careful now. They're likely to take that as a compliment.
Bwian keeps telling everyone he has me killfiled. He also tells other
people to killfile me. I think he's angry as I referred to him as a
pathetic little jobsworth with nothing of use to add to any threads. All
he ever does is tell people off and parrot Heathfield from what I can
gather. Bill adds more value.
Jul 30 '08 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.