Swetha,

'\' in C is used to denote a escape sequence in C strings (and also in many
other languages).
e.g '\n' is for New Line '\n' is counted as one character.
Now '\ooo' is for an ASCII in octal representation.
here is the list of all escape sequences:
http://msdn.microsoft.com/en-us/library/h21280bw(v=vs.80).aspx

So for your string : "\12345s\n"
here '\123' is an ASCII in octal, hence one character.
rest you know about the characters: so length = '\123'(1) + 3 + '\n'(1) = 5.

I suggest you try with other combinations with '\' and print the output.
They will definitely show some weird stuffs :)

Hope that helps.
On 25 July 2011 22:53, swetha rahul <swetharahu...@gmail.com> wrote:

> char *s="\12345s\n";
> printf("\n %d",strlen(s));
>
> The output is 5...?? But how.??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
___________________________________________________________________________________________________________

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to