Using net use command in C++?



 DEVELOP > c-Plus-Plus > Using net use command in C++?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "chanchoth"
Date: 16 Jan 2005 10:36:06 PM
Object: Using net use command in C++?
Hi everybody,
I am new to C++ and I would like to use this program to give the home
directory to each user.
My program is as below:
#include "iostream.h"
int main()
{
cout << "Home Directory for this user" << endl;
system("net use H: \\TEST\Home\%username%");
return 0;
}
I've got the message as below:
--------------------Configuration: HomeDirectory - Win32 Debug-----
Compiling...
HomeDirectory.cpp
D:\HomeDirectory\HomeDirectory.cpp(10) : error C2065: 'system' :
undeclared identifier
D:\HomeDirectory\HomeDirectory.cpp(10) : warning C4129: 'H' :
unrecognized character escape sequence
D:\HomeDirectory\HomeDirectory.cpp(10) : warning C4129: '%' :
unrecognized character escape sequence
Error executing cl.exe.
HomeDirectory.obj - 1 error(s), 2 warning(s)
Thank you so much for your assistance.
.

User: "Jerry Coffin"

Title: Re: Using net use command in C++? 17 Jan 2005 10:11:42 AM
[ ... ]

system("net use H: \\TEST\Home\%username%");

The answer has been hinted at, but not yet given correctly. You need
two backslashes in your source code to produce a single backslash.
system("net use H: \\\\TEST\\Home\\%username%");
P.S. You might want to ask on comp.os.ms-windows.programmer.win32 about
WNetAddConnection{2|3} to do the job without an external program.
--
Later,
Jerry.
The universe is a figment of its own imagination.
.

User: "Gianni Mariani"

Title: Re: Using net use command in C++? 16 Jan 2005 11:32:59 PM
chanchoth wrote:

Hi everybody,

I am new to C++ and I would like to use this program to give the home
directory to each user.

My program is as below:

#include "iostream.h"

int main()

{
cout << "Home Directory for this user" << endl;
system("net use H: \\TEST\Home\%username%");

The `/` character is somthing special in C/C++ characters
and strings. If you want a true `/` character then you
need to escape it with itself.
e.g.
"net use H:\\\\TEST\\Home\\%username%"

return 0;
}

I've got the message as below:
--------------------Configuration: HomeDirectory - Win32 Debug-----
Compiling...
HomeDirectory.cpp
D:\HomeDirectory\HomeDirectory.cpp(10) : error C2065: 'system' :
undeclared identifier
D:\HomeDirectory\HomeDirectory.cpp(10) : warning C4129: 'H' :
unrecognized character escape sequence
D:\HomeDirectory\HomeDirectory.cpp(10) : warning C4129: '%' :
unrecognized character escape sequence
Error executing cl.exe.

HomeDirectory.obj - 1 error(s), 2 warning(s)
Thank you so much for your assistance.

.

User: "Ioannis Vranos"

Title: Re: Using net use command in C++? 17 Jan 2005 02:11:06 AM
chanchoth wrote:

Hi everybody,

I am new to C++ and I would like to use this program to give the home
directory to each user.

My program is as below:

// For std::cout
#include <iostream>
// For std::system
#include <cstdlib>
// For std::endl
#include <ostream>
int main()
{
using namespace std;
cout << "Home Directory for this user" << endl;
// I do not know "net use", however I think it should be:
system("net use H:\\TEST\\Home\\%username%");
return 0;
}
--
Ioannis Vranos
http://www23.brinkster.com/noicys
.
User: "Richards Noah \IFR LIT MET"

Title: Re: Using net use command in C++? 17 Jan 2005 01:50:50 PM
"Ioannis Vranos" <ivr@remove.this.grad.com> wrote in message
news:1105949465.709892@athnrd02...

chanchoth wrote:

Hi everybody,

I am new to C++ and I would like to use this program to give the home
directory to each user.

My program is as below:




// For std::cout
#include <iostream>

// For std::system
#include <cstdlib>

// For std::endl
#include <ostream>

<snip>
Including <ostream> after including <iostream> is unnecessarily redundant,
don't you think?
.
User: "Mike Wahler"

Title: Re: Using net use command in C++? 17 Jan 2005 02:59:45 PM
"Richards Noah (IFR LIT MET)" <Noah.Richards@infineon.com> wrote in message
news:csh4us$fmd$1@athen03.muc.infineon.com...

"Ioannis Vranos" <ivr@remove.this.grad.com> wrote in message
news:1105949465.709892@athnrd02...

chanchoth wrote:

Hi everybody,

I am new to C++ and I would like to use this program to give the home
directory to each user.

My program is as below:




// For std::cout
#include <iostream>

// For std::system
#include <cstdlib>

// For std::endl
#include <ostream>


<snip>

Including <ostream> after including <iostream> is unnecessarily redundant,
don't you think?

No. 'endl' is declared by <ostream>, not <iostream>.
Many implementations' <iostream> header does #include
<ostream>, but there's no requirement that it does.
I seem to recall a recent lengthy debate about this,
here, or at alt.comp.lang.learn.c-c++.
If you need to refer to a standard library name, #include
the header that declares it. Don't depend upon possible
(or common) implementation details.
-Mike
.

User: "Ioannis Vranos"

Title: Re: Using net use command in C++? 17 Jan 2005 02:44:46 PM
Richards Noah (IFR LIT MET) wrote:

Including <ostream> after including <iostream> is unnecessarily redundant,
don't you think?

http://groups.google.com/groups?q=%3Costream%3E+author:bazarov&hl=el&lr=&scoring=d&selm=9pFAd.34179%24NC6.10901%40newsread1.mlpsca01.us.to.verio.net&rnum=2
http://groups.google.com/groups?hl=el&lr=&frame=right&rnum=11&thl=848125052,848124319,848125489,848124915,848121206,848120485,848173730,848165971,848131067,848127669,848129511,848106490&seekm=qsjBd.371%24Q%254.311%40fe11.lga#link17
--
Ioannis Vranos
http://www23.brinkster.com/noicys
.
User: "Gianni Mariani"

Title: Re: Using net use command in C++? 17 Jan 2005 07:58:16 PM
Ioannis Vranos wrote:

Richards Noah (IFR LIT MET) wrote:

Including <ostream> after including <iostream> is unnecessarily
redundant,
don't you think?




http://groups.google.com/groups?q=%3Costream%3E+author:bazarov&hl=el&lr=&scoring=d&selm=9pFAd.34179%24NC6.10901%40newsread1.mlpsca01.us.to.verio.net&rnum=2


http://groups.google.com/groups?hl=el&lr=&frame=right&rnum=11&thl=848125052,848124319,848125489,848124915,848121206,848120485,848173730,848165971,848131067,848127669,848129511,848106490&seekm=qsjBd.371%24Q%254.311%40fe11.lga#link17

http://groups-beta.google.com/group/comp.std.c++/browse_frm/thread/93e1f28fa4058818/fa8b7f3087e6a081?tvc=1&scrollSave=&&d#fa8b7f3087e6a081
Including a little debate going on right now ...
.




User: "Debian User"

Title: Re: Using net use command in C++? 16 Jan 2005 11:36:00 PM
system() is defined in stdlib.h
#include <stdlib.h>
chanchoth <Chanchoth.Puth@gmail.com> wrote:

Hi everybody,

I am new to C++ and I would like to use this program to give the home
directory to each user.

My program is as below:

#include "iostream.h"

int main()

{
cout << "Home Directory for this user" << endl;
system("net use H: \\TEST\Home\%username%");
return 0;
}

I've got the message as below:
--------------------Configuration: HomeDirectory - Win32 Debug-----
Compiling...
HomeDirectory.cpp
D:\HomeDirectory\HomeDirectory.cpp(10) : error C2065: 'system' :
undeclared identifier
D:\HomeDirectory\HomeDirectory.cpp(10) : warning C4129: 'H' :
unrecognized character escape sequence
D:\HomeDirectory\HomeDirectory.cpp(10) : warning C4129: '%' :
unrecognized character escape sequence
Error executing cl.exe.

HomeDirectory.obj - 1 error(s), 2 warning(s)
Thank you so much for your assistance.

.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER