473,657 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Command Line Argument with & and ^

Hi,

I'm trying to create a program that reads these two characters (& and
^) as arguments to a funcion. However since they are part of the
operational system characters with special funcions when in an
argumento to a function, whenever I put them in my list of arguments, I
get errors and can't parse them to my program.

Any Ideas on how to use them inside my application? Ah, and i don't
want to use other arguments before them so it can be recognized, like
/^ or -&, ofr example.

Thanks a lot for any help.

Apr 2 '06 #1
7 2820
* mackmelo:
[off-topic]


Please post OS-related question in a newsgroup for that OS.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 2 '06 #2
Hi,

I'm sorry, but this is not off-topic. Maybe I didn't explain myself
very clearly.

I'm creating a C++ application that needs command line arguments (argv
and argc). The problem is that when I try to use ^and & in the command
line - for example (the name of the program is run.exe):

run asdf jasdas ^

I should get three arguments (other than the program itself) but I
can't read the last argument, the ^. When I try the & a different error
occurs, but it seems to be the same problem. ^ and & are reserved
arguments used by the operational system to do something at the command
line.

What should I do inside my code (C++) to get these arguments as valid
and accountable argumetns?

I hope that with this explanation you may consider this post as
on-topic.

Thanks.

Apr 2 '06 #3
mackmelo wrote:
Hi,

I'm sorry, but this is not off-topic. Maybe I didn't explain myself
very clearly.

I'm creating a C++ application that needs command line arguments (argv
and argc). The problem is that when I try to use ^and & in the command
line - for example (the name of the program is run.exe):

run asdf jasdas ^

I should get three arguments (other than the program itself) but I
can't read the last argument, the ^. When I try the & a different error
occurs, but it seems to be the same problem. ^ and & are reserved
arguments used by the operational system to do something at the command
line.

What should I do inside my code (C++) to get these arguments as valid
and accountable argumetns?

I hope that with this explanation you may consider this post as
on-topic.

Thanks.


There is nothing you can do in the C++ code.
The system's command parser processes those special symbols even
before it starts your program.

Those characters as 'special' on many Operating Systems, stick
with alphanumerics

Larry
Apr 2 '06 #4
* mackmelo:

I'm sorry, but this is not off-topic. Maybe I didn't explain myself
very clearly.


It is 100% off-topic, and you did explain it very clearly.

It is purely an issue with one specific Microsoft Windows program
(namely, the Windows program [cmd.exe]), and so has /nothing whatsoever/
to do with any programming language, much less C++.

Please post to an appropriate newsgroup, such as e.g.
[comp.os.ms-windows.program mer.win32].

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 2 '06 #5
Hello,

I want to thank you for your answers and that the language can't deal
with these characters. I'll try to explain this to my professor and I
really hope he accepts this explanation. :)

Thanks for your help.

Apr 3 '06 #6
mackmelo wrote:
Hello,

I want to thank you for your answers and that the language can't deal
with these characters. I'll try to explain this to my professor and I
really hope he accepts this explanation. :)

Thanks for your help.


I think you misunderstand.. .

The languge (your program) never sees these characters.
The characters are interpreted by the Operating System
(and possibly discarded) before the Operating System
even launches your program. The Operating System
does not pass these chars to your program - that's not
the program (or the language's fault).

Larry
Apr 3 '06 #7
Alf P. Steinbach wrote:
* mackmelo:

I'm sorry, but this is not off-topic. Maybe I didn't explain myself
very clearly.


It is 100% off-topic, and you did explain it very clearly.

It is purely an issue with one specific Microsoft Windows program
(namely, the Windows program [cmd.exe]), and so has /nothing whatsoever/
to do with any programming language, much less C++.

Please post to an appropriate newsgroup, such as e.g.
[comp.os.ms-windows.program mer.win32].


Brief explanation, as the question is asked.

cmd.exe interprets '^' as an escape character (like '\' in C/C++
strings).
For example, a command
echo hello > world
passes "hello" to echo and forwards its output to a file "world"
To escape control characters of command line, use ^ prefix:
echo hello ^>^^.^^^< my name is Neko
passes "hello >^.^< my name is Neko" to echo and doesn't redirect.

& means serial execution of commands
echo hello & echo world
is treated as
echo hello
echo world
To escape &, use ^ as above.

Apr 3 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3442
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
7
9870
by: Bernd Danberg | last post by:
Hi, I have a real strange problem with the command line arguments given to the main-function and together with using std::string: #include <string> int _tmain(int argc, _TCHAR* argv) { std::string str(argv); println(str.c_str());
2
4186
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain how to use Command-Line Arguments inside C program.
3
5404
by: Shailesh Humbad | last post by:
I want to set a command-line argument for a Windows service that I programmed in VB.Net. This ought to be available from the service installer classes, but I can not find any such property. What I end up having to do is modify the registry directly from a separate installer program, which from a deployment perspective is--let's just say less than optimal. The second problem I have is that when the Win2K service control manager runs...
1
7893
by: amirmira | last post by:
I would like to set command line arguments to a service at install time. I need to do this because I need to get information from different registry locations depending on my command line argument. I have to do it this way as the consumer of the service should not be able to change the argument - except by uninstalling and reinstalling the service. I created the service and the service itself works great. However, when I try to install...
34
6849
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: 1) get whole string of input line 2) preset table of strings matching <command> 3) preset table of function calls
6
2353
by: =?Utf-8?B?Rm9ycmVzdCBIZWxsZXI=?= | last post by:
The only code that is helpful is this: fp = New IO.StreamReader(filename, New System.Text.UnicodeEncoding(True, False), False) If I pass a command line argument to my program that is not from Visual Studio.NET is debug mode, the above code won't work, even though filename is not changed whether I pass a command line argument or not. By not work, I mean it will set fp.EndOfStream to true and fp.Peek() returns -1. The command line argument...
51
4122
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under Command Prompt or Browser or some other application? Ojas.
2
3966
by: =?Utf-8?B?UmFtb24gR2VuZQ==?= | last post by:
Hello: I am building a console application and I am having an issue with the command line arguments. A couple of my arguments are paths and they are usually enclosed in double quotes. If one of the paths ends up in "\", it causes the closing double quote to be ignored and the argument gets concatenated with all the subsequent arguments until another double quote is found or until the end of the string. Example:
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.