A small comment, in most compilers, in c++, it's better to define everything
so you never get un-expected results, so
char s[3][4]={"000","001","010"};
s[0][3] is not necessary '\0' but could be anything, so better safe write it
as:
char s[3][4]={"000\0","001\0","010\0"};
-- Amahdy AbdElAziz
http://www.linkedin.com/in/amahdyabdelaziz
On Sun, Feb 27, 2011 at 14:01, MJ_India <[email protected]> wrote:
> It is not C, but C++.
> And you are not considering extra byte for null character after
> string. (Change string length from 3 to 4)
>
> On Feb 27, 8:57 pm, Shoubhik <[email protected]> wrote:
> > #include<stdio.h>
> > #include<string.h>
> >
> > int main(){
> > char s[3][3]={"000","001","010"};
> > puts(s[0]);
> > puts(s[1]);
> > puts(s[2]);
> > return 0;
> >
> > }
> >
> > the output im expecting is:
> >
> > 000
> > 001
> > 010
> >
> > instead,
> > this is the output I'm getting,
> >
> > 000001010
> > 001010
> > 010
> >
> > where am i wrong ?
> >
> > I excuted the code here... http://codepad.org/mg8mHyY7
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en.