March 13, 2004
Expanation:

At first I actually tried to read each character
from the char[] which is returned , but then I decided that I would use
split(which as you know returns a char[][]) so that I could read the whole
line(group name) in a char[] instead of a char at a time, unfortunately when
I changed from char to char[] I left the char[] name as c because I was in a
hurry to test and partly because I am lazy :o))

Phill.


"Ant" <duitoolkit@yahoo.ca> wrote in message news:pan.2004.03.13.04.22.24.989634@yahoo.ca...
> On Sat, 13 Mar 2004 15:31:51 +1100, Phill wrote:
>
> >
> > "Manfred Nowak" <svv1999@hotmail.com> wrote in message news:c2tml8$383$1@digitaldaemon.com...
> >> Phill wrote:
> >>
> >> [...]
> >> >   foreach(char[] c; ch)
> >> >   {
> >> >     printf("c = \n", c);
> >> >   }
> >> [...]
> >>
> >> printf("c = %.*s\n", c);
> >>
> >> There are some conventions most programmers trust in:
> >>
> >>   `i' is a name used for a variable of integer type containing running
> >>   content
> >>   `n' is a name used for a variable of integer type containing an upper
> > bound
> >>   `c' is a name used for a variable of character type
> >>   ...
> >>
> >> So long.
> >>
> >
> > Yes, and???
> >
> > Phill
>
> that's why my suggestions was wrong
> I saw 'char' and 'c' so my brain ignored the '[]'
> (actually I just looked at the printf and saw 'c')
>
> You wouldn't do:
>
> char[] myCharacter;
> char myString;
>
> would you?
>
> Ant
>


March 13, 2004
Thanks to everyone!

Phill.


"Phill" <phill@pacific.net.au> wrote in message news:c2tgjg$2pqj$1@digitaldaemon.com...
> Im trying to iterate through a char[][]
> with foreach.
>
> It prints the correct amount of index's of "ch", but there is no value there.
>
> ie: the following code prints
>
> c =
> c =
> c =
>
> names is a char[]
> ---------------------------------
>  char[][] ch = split(names,"\n");
>   foreach(char[] c; ch)
>        {
>              printf("c = \n", c);
>
>          }
>
> Any help is appreciated.
>
> Phill.
>
>
>
>


March 13, 2004
Phill wrote:

[...]
> because I was in a hurry to test and partly because I am lazy

Do you agree then, that your conduct may be a suitable object of negative criticism?

Instead of reasoning over your code yourself, you was so lazy to post to
the world a fact about `foreach' whereas you had no evidence, that your
code worked without the `foreach', thereby allocating the time of at least
three helpful and unlazy people, not accounting those who already
spent or will spend time to read your posting and the answers for only
recognizing, a person in a hurry, that was drinking coffee while the world
started circling around its generated non issue.

How do you want to pay that back?

So long.
March 13, 2004
"Manfred Nowak" <svv1999@hotmail.com> wrote in message news:c2uhre$1fdg$1@digitaldaemon.com...
> Phill wrote:
>
> [...]
> > because I was in a hurry to test and partly because I am lazy
>
> Do you agree then, that your conduct may be a suitable object of negative criticism?

only to a pedant.

> Instead of reasoning over your code yourself, you was so lazy to post to
> the world a fact about `foreach' whereas you had no evidence, that your
> code worked without the `foreach', thereby allocating the time of at least
> three helpful and unlazy people, not accounting those who already
> spent or will spend time to read your posting and the answers for only
> recognizing, a person in a hurry, that was drinking coffee while the world
> started circling around its generated non issue.

If you READ my post and READ the code you will see that the only REAL
problem with my code was I had this:
printf("c = \n",c);

instead of this:

printf("c = %*.s\n",c);

The reason that I used this:
printf("c = \n",c);

Is because I did not know about this:

printf("c = %*.s\n",c);

My lack of knowledge of the formatting of strings is as I stated in an
earlier post
because I have hardly any programming experience in C or C++.
I only know Java, but I am trying to learn this D language.

As this is about the only place one can come to get any questions answered about the use of it, this is where I come.

You bitching about peoples lack of knowledge is not going to do anything for the popularity of D, so why dont you get off you high horse.........

So long!



>
> How do you want to pay that back?
>
> So long.


March 13, 2004
> You bitching about peoples lack of knowledge is not going to do anything for the popularity of D, so why dont you get off you high horse.........
> 
> So long!
> 
> 

Phil, don't worry yourself too much about responses such as Manfred's.
Your question was innocent enough. No one is forced to read or even answer
posts, so whoever complains the way he did has to take responsibility for
themselves. Just give him the benefit of the doubt and assume that he had
a stressful day and was tired. It happens to everyone now and again.
Actually, cranky retorts are quite rare in this D group, thank goodness :-).

In truth, the way Manfred wrote his response, I almost thought he was joking around.  It was rather a mouthful to read, consisting of one looooong sentence linked together with several clauses.  Try reading it aloud without taking a breath ;-).

Peacefully,

John
March 14, 2004
Thanks for the URL Justin, its great!

Phill.

"J C Calvarese" <jcc7@cox.net> wrote in message news:c2tli3$12e$1@digitaldaemon.com...
> Phill wrote:
> > Im trying to iterate through a char[][]
> > with foreach.
> >
> > It prints the correct amount of index's of "ch", but there is no value there.
> >
> > ie: the following code prints
> >
> > c =
> > c =
> > c =
> >
> > names is a char[]
> > ---------------------------------
> >  char[][] ch = split(names,"\n");
> >   foreach(char[] c; ch)
> >        {
> >              printf("c = \n", c);
>
> Try:
> printf("%.*s = \n", c);
>
> It's a char[] so "%.*s" it the proper format string.
> (See also http://www.wikiservice.at/d/wiki.cgi?HowTo/printf)
>
> >
> >          }
> >
> > Any help is appreciated.
> >
> > Phill.
>
> Here's a full example, so that everyone can try it out:
>
> import std.string;
>
> void main()
> {
>   char[] names = "200 digitalmars.com InterNetNews NNRP server INN 2.3.2
> ready (posting ok).
> Sending List request.....
> 215 Newsgroups in form \"group high low flags\".
> c++ 0000003792 0000000001 y
> c++.stl 0000000083 0000000001 y
> c++.stl.hp 0000000010 0000000001 y
> c++.stl.sgi 0000000039 0000000001 y
> c++.stl.port 0000000176 0000000001 y
> c++.idde 0000000402 0000000001 y
> c++.command-line 0000000402 0000000001 y
> c++.rtl 0000000059 0000000001 y
> c++.mfc 0000000347 0000000001 y
> c++.atl 0000000041 0000000001 y
> c++.announce 0000000594 0000000001 y
> c++.dos 0000000217 0000000001 y
> c++.dos.16-bits 0000000156 0000000001 y
> c++.dos.32-bits 0000000416 0000000001 y
> c++.windows 0000000006 0000000001 y
> c++.windows.16-bits 0000000071 0000000001 y
> c++.windows.32-bits 0000000757 0000000001 y
> c++.chat 0000000348 0000000001 y
> D 0000025479 0000000001 y
> D.gnu 0000000488 0000000001 y
> DMDScript 0000000040 0000000001 y
> c++.beta 0000000357 0000000001 y
> c++.stlsoft 0000000188 0000000001 y
> c++.wxwindows 0000000172 0000000001 y";
>
>   char[][] ch = split(names,"\n");
>    foreach(char[] c; ch)
>    {
>      printf("%.*s = \n", c);
>    }
> }
>
> --
> Justin
> http://jcc_7.tripod.com/d/


March 14, 2004
"John Reimer" <jjreimer@telus.net> wrote in message news:pan.2004.03.13.09.51.20.547117@telus.net...
> > You bitching about peoples lack of knowledge is not going to do anything for the popularity of D, so why dont you get off you high horse.........
> >
> > So long!
> >
> >
>
> Phil, don't worry yourself too much about responses such as Manfred's. Your question was innocent enough. No one is forced to read or even answer posts, so whoever complains the way he did has to take responsibility for themselves. Just give him the benefit of the doubt and assume that he had a stressful day and was tired. It happens to everyone now and again. Actually, cranky retorts are quite rare in this D group, thank goodness
:-).
>
> In truth, the way Manfred wrote his response, I almost thought he was joking around.  It was rather a mouthful to read, consisting of one looooong sentence linked together with several clauses.  Try reading it aloud without taking a breath ;-).

Yes, its very similar to taking the semi colons
out of your code isnt it? :o))

Phill.

>
> Peacefully,
>
> John


March 14, 2004
Andrew Edwards wrote:

> sorry, that should be %.*s


I always get these mixed up to.  I came up with a poem (or whatever you call it):

star before s but not before dot

-- 
-Anderson: http://badmama.com.au/~anderson/
March 14, 2004
J Anderson wrote:

> Andrew Edwards wrote:
> 
>> sorry, that should be %.*s
> 
> 
> I always get these mixed up to.  I came up with a poem (or whatever you
> call it):
> 
> star before s but not before dot
> 

I know. I've had the same trouble remembering it.  Then I recalled that if one thinks of s as representing a pointer type then its easy to remember that the asterisk should be right next to "variable" (for those familiar with C/C++ at least).  That has helped me.

Later,

John
1 2
Next ›   Last »