Thread Subject:
What's the difference of \\ and \ when used in sprintf?

Subject: What's the difference of \\ and \ when used in sprintf?

From: Jixin

Date: 1 Jul, 2013 01:03:19

Message: 1 of 3

Hello

I tried to generate a file name by sprintf as:

filename = sprintf('D:\...\%03d', 1);

and it doesn't work.
Then I changed it into:

filename = sprintf('D:\\...\\%03d',1);

and it works.
So what's happening here?
Thanks guys

Jixin

Subject: What's the difference of \\ and \ when used in sprintf?

From: dpb

Date: 1 Jul, 2013 02:01:36

Message: 2 of 3

On 6/30/2013 8:03 PM, Jixin wrote:
...

> I tried to generate a file name by sprintf as:
>
> filename = sprintf('D:\...\%03d', 1);
>
> and it doesn't work.
...
> filename = sprintf('D:\\...\\%03d',1);
>
> and it works.
> So what's happening here?
...

doc sprintf

page down in the format spec section on 'Escape characters' and all will
become clear...

--

Subject: What's the difference of \\ and \ when used in sprintf?

From: Jixin

Date: 1 Jul, 2013 03:36:10

Message: 3 of 3

dpb <none@non.net> wrote in message <kqqnt1$p84$1@speranza.aioe.org>...
> On 6/30/2013 8:03 PM, Jixin wrote:
> ...
>
> > I tried to generate a file name by sprintf as:
> >
> > filename = sprintf('D:\...\%03d', 1);
> >
> > and it doesn't work.
> ...
> > filename = sprintf('D:\\...\\%03d',1);
> >
> > and it works.
> > So what's happening here?
> ...
>
> doc sprintf
>
> page down in the format spec section on 'Escape characters' and all will
> become clear...
>
> --

Thanks dpb :)

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us