From: atmkoh on
I generally use Visual Basic both vb6 and dot net variants. Now I am
using console visual c.
The problem is that I need to get an argument from the user as to the
working directory such as "E:\work\project\data"

In c we have to use "E:\\WORK\\project\\data"

How to I append the extra "\" to the string?

Seasons Greetings and Best regards

Andrew
From: Igor Tandetnik on
atmkoh <atmkoh(a)yahoo.co.uk> wrote:
> I generally use Visual Basic both vb6 and dot net variants. Now I am
> using console visual c.
> The problem is that I need to get an argument from the user as to the
> working directory such as "E:\work\project\data"
>
> In c we have to use "E:\\WORK\\project\\data"
>
> How to I append the extra "\" to the string?

You only need to write extra \ in string literals, because otherwise it's interpreted as an escape character. E.g. "\n" is a string containing a single line-feed character, while "\\n" is a string containing two characters, backslash and 'n'.

In user-entered data, or generally in strings that are generated programmatically, you don't need to double backslashes.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925

From: Victor Bazarov on
atmkoh wrote:
> I generally use Visual Basic both vb6 and dot net variants. Now I am
> using console visual c.
> The problem is that I need to get an argument from the user as to the
> working directory such as "E:\work\project\data"

OK

> In c we have to use "E:\\WORK\\project\\data"

Only if it's inside the C program and is the actual string literal. If
it's an argument coming from a file or the command line, we don't have
to double the backslashes.

> How to I append the extra "\" to the string?

Where? Try without appending the extra \.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask