|
the code below create a folder in drive E:\ called autorun.inf and other line to create inside autorun.inf folder a text file called protection.txt
now what i want is instead of creating these things in drive E:\ i want the user to enter the drive letter that he wants then these files will be created in the entered drive
#include <direct.h>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
_mkdir("e:/autorun.inf");
ofstream output("e:\\autorun.inf\\protection.txt",ios::out);
output.close();
return 0;
}
Thanks in advance
|
|
|
|
|
whats the problem in achieving it?
accept the drive letter from user,
form a string that has to be passed to _mkdir, and pass it.
first try it, and then post here if you have any problem. we will definitely help you.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Hi .
Is this what you want?
#include <direct.h>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
char root;
char path[64];
cin >> root;
sprintf_s(path, "%c:/autorun.inf", root);
_mkdir(path);
sprintf_s(path, "%s/protection.txt", path);
ofstream output(path,ios::out);
output.close();
return 0;
}
|
|
|
|
|
thank you very much this exactly what i want
but if u do not mind i want to ask u some questions about the code that u wrote
#include <direct.h>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
char root;
char path[64];
cin >> root;
sprintf_s(path, "%c:/autorun.inf", root);
_mkdir(path);
sprintf_s(path, "%s/protection.txt", path);
ofstream output(path,ios::out);
output.close();
return 0;
}
again thank u very much
|
|
|
|
|
I'm a chinese, my English may be hard to read, I'm sorry for that. But i will try to explain it.
jon ray wrote: char path[64]; //why did u declare path as char and set it to 64
64 isn't a regular number, I got it by counting the length of your longest full path "e:\\autorun.inf\\protection.txt", and just pick a number more than it.
jon ray wrote: sprintf_s(path, "%c:/autorun.inf", root); //what does this thing mean (%c)
%c is mean that it's a character but not others(string), and it's value is determined by 'root'
jon ray wrote: sprintf_s(path, "%s/protection.txt", path); //why did u put two (path) and why did u put here %s instead of %c
%s is mean that it's a string, and it's value is determined by 'path'.
the second 'path' is use to replace the '%s', and then put the result "%s/protection.txt" to the first 'path', now 'path' has become the full path what you want.
|
|
|
|
|
Since you are using C++, try:
string path = root + ":/autorun.inf";
_mkdir(path);
path = path + "/protection.txt";
ofstream output(path, ios::out);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
how to add command buttons to SDI application?
|
|
|
|
|
where do u want them to be added?
you mean on the View area?
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
|
create the button dynamically.
like
CButton b;
b.Create(...);
try to browse for CButton::Create(...)function.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
|
|
If you use CFormView as the view class of the SDI application, you can add any controls to its dialog template just like a dialog based application.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
In my current project I will be receiving fixed type packets. I need to validate the checksum on those fixed packets..once the validation is successful. I need to strip off the header and buffer the remaining content. And I need to keep doing this in sequential order as the packets I receive. PAckets coming are infinite. So I am having difficutly in how do I handle this entire scenario in C++ programming. I am new bee in Object Oriented Programming... Any help would be great.
THANKS!
|
|
|
|
|
You could create a vector<byte> and keep appending the contents into this vector using vector<byte>::insert at the location vector<byte>::end.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
resolvequestion wrote: I am new bee in Object Oriented Programming
What kind of new bee are you, honeybee or bumblebee?
|
|
|
|
|
How are the packets going to be processed? You say "PAckets coming are infinite" which implies you must use and discard data, otherwise your machine's memory would fill up.
If you want to process packets in the order that they arrive, I'd probably use a deque rather than the vector that superman mentioned, because a deque has good "delete from front" characteristics when compared with a vector.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart Dootson & Superman !
I will be receiving certain amount of packets but I am not sure exactly how much. There will no memory problem as certainly its being taken under consideration that the received packets will be at certain limit it will not exceed.
whats the difference between using vector versus dequeue or queue technique.
I am explaining my scenario . I have reader thread that will do blocking read and once it receives the first packet which will be of 20W with 1W header with it.. I need to calculate checksum of the 20W packet received. Than I need to read certain fields and need to decide where it needs to be buffered. Before buffering these packets I need to strip off the 1W header. Once the buffering is complete say I might receieve 500 packets of size 20Word. After I stop receving the packets. I need to analyze the packets that being buffered. And these packets are of 2 types theere might be 2W packet and 260W packet or partial packet and each of these packet will have header so. first I need to read the packet header of the first received packet inthe buffer and base don that I need to dispatch those packets to its destined location or hand over to the designated handler.
So confusion is whats the best efficient technique I should use. Using simple array is not best option so thought of asking here. Also how do Istrip off the header from the packet.
Any help woul dbe appreciated. I have just started coding but have not really much coded in C++ .. I am learning by dng google or reading previos discussion here on forum
THANKS!!!!
|
|
|
|
|
How to read and display the height map in STL File?
i want to read the height map from STL file and display it in the picture control(MFC).
Any suggestion? am i need to using the openGL?
i am totally new in this 3D area...
|
|
|
|
|
anyone can help me?please
|
|
|
|
|
You may have a look at GLC_player [^] sources, or refer to the STL format specifications [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i read the STL format article already but still no ideal how to take the heightmap value and put it into matrix..zzz
the value from STL is like this
facet normal -0.1121196661 -0.0743282699 0.9909109389
outer loop
vertex 58.7546923638 62.1518674227 -611.4251952748
vertex 58.7132072061 61.7884042612 -611.4571526271
vertex 59.0884428989 61.5937838377 -611.4292939164
endloop
endfacet
the heightmap value == y?
p/s: what i know from the article above is -611.42xxxx all is a y value.
|
|
|
|
|
I'm fairly new to windows programming and use the MessageBox function a lot to see what going on with code. The problem I have is when using API functions that return various types. I want to see the values returned. Anyone know how to do conversion on these returned values so they can be displayed in a MessageBox?
|
|
|
|
|
you can use _sntprintf (TCHAR, char-counted, sprintf) to build a string:
int iVal = 100;
TCHAR buf[100];
_sntprintf(buf, "this is my integer: %d", iVal);
MessageBox(buf);
|
|
|
|
|
egerving wrote: use the MessageBox function a lot to see what going on with code
Why are you not using a debugger?
egerving wrote: API functions that return various types
Example? Again, if you use the debugger you'll see the return values.
|
|
|
|