|
What's wrong with
fullpath(argv[1]);
??
|
|
|
|
|
I'm assuming that you are passing in the argument so the caller would need to pass it in. Many windows functions look for the file name in the order of current directory then traverse the path. But if you need to get the entire file name that will have to be passed in.
If the file is in the current directory you can use findfirstfile findnextfile functions.
a programmer traped in a thugs body
|
|
|
|
|
If you want the fullpath relative to the current working folder you can use the _fullpath function as mentioned by W. Kleinschmit.
If you want to search for the file and then get the full path of that file you can use PathFindOnPath API.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi I got a project which involves interprocess communication. I uses pipes because it's only happend in one machine. It seems everything should be perfect. However, When I try to connect The Client and The Server. I always have an Error number 231 ( All pipe instances are busy) when I try to create file in client side.
Client --> Create File, Write File
Server --> Create Named Pipes, Read File
here is some of the code in my programs
m_hPipeHandle = INVALID_HANDLE_VALUE;
m_hPipeHandle = CreateFile(ISOCOMSPIPE,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(m_hPipeHandle == INVALID_HANDLE_VALUE)
{
int iRet = GetLastError();
printf("Error number %d",iRet);
}
closeHandle(m_hPipeHandle);
Is there anything wrong in the attributes/ missing attributes when I want to create the file ?
Thx
|
|
|
|
|
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99331[^]
Can someone check to see if the above bug was fixed in VC++ 2008.
I've got some code that is based on the assumption that virtual properties works, i want to know if i have to modify the code or upgrade to 2008.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
You'll have to modify the code - that behaviour is still present in VS2008
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Based on their bug response i'm not too surprised.
Thanks for checking, i really didn't want to install VC 2008 Express just to check.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi all,
I have written a Javascript code that moves a dot around the screen randomly, and it does output my result at the end of the code, however I feel I have gone as far as I can with this code and would like a different way to create the program. First thought was using C++,
Here is the code:
<code> "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<style type="text/css">
body {
overflow:hidden;
}
#container div,#timer {
width:250px;
line-height:30px;
padding-left:10px;
border:3px double #999;
margin:4px 0;
}
.hide {
display:none;
}
#dot {
width20px;
font-size:36px;
color:#f00;
position:absolute;
}
#coords {
padding:10px;
border:3px double #999;
margin-top:10px;
font-family:courier,monospace;
font-size:12px;
text-align:justify;
}
</style>
<script type="text/javascript">
/****** these values may be edited *****/
var iterations=2000;
var height=999;
var width=999;
var temp1=500;
var temp2=500;
/***************************************/
var speed=10;
var c=0;
var ur=0;
var ul=0;
var dr=0;
var dl=0;
var s=0;
var xc=0;
var yc=0;
if(window.addEventListener){
window.addEventListener('load',randomtest,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',randomtest);
}
}
function randomtest(){
secs=Math.floor((iterations-c)*speed/1000);
x=Math.floor(Math.random()*width);
y=Math.floor(Math.random()*height);
document.getElementById('coords').innerHTML+=x+':'+y+', ';
document.getElementById('dot').style.left=x+'px';
document.getElementById('dot').style.top=y+'px';
if((x>=temp2)&&(y>=temp1)) {
ur++;
temp1=x;
temp2=y;
}
else {
if((x<=temp2)&&(y>=temp1)) {
ul++;
temp1=x;
temp2=y;
}
else {
if((x>=temp2)&&(y<=temp1)) {
dr++;
temp1=x;
temp2=y;
}
else {
if((x<=temp2)&&(y<=temp1)) {
dl++;
temp1=x;
temp2=y;
}
}
}
}
c++;
xc=xc+x;
yc=yc+y;
if(c>iterations) {
clearTimeout(rnd);
document.getElementById('timer').className='hide';
document.getElementById('dot').className='hide';
document.body.style.overflow='visible';
document.getElementById('upright').firstChild.nodeValue='up right total='+ur;
document.getElementById('upleft').firstChild.nodeValue='up left total='+ul;
document.getElementById('downright').firstChild.nodeValue='down right total='+dr;
document.getElementById('downleft').firstChild.nodeValue='down left total='+dl;
document.getElementById('container').className='';
document.getElementById('coords').className='';
alert('average coords are n\nx='+Math.round(xc/c)+'\ny='+Math.round(yc/c));
return;
}
document.getElementById('timer').firstChild.nodeValue='time remaining : '+secs+' seconds.';
rnd=setTimeout('randomtest()',speed);
}
</script>
</meta></meta></meta></head>
<body>
<div id="timer"> </div>
<div id="container" class="hide">
<div id="upright"> </div>
<div id="upleft"> </div>
<div id="downright"> </div>
<div id="downleft"> </div>
</div>
<div id="dot">•</div>
<div id="coords" class="hide"></div>
</body>
</html>
</code>
Can anyone help out with some C++ code to get me started? I would be forever greatful.
Skie
|
|
|
|
|
A thumbwheel switch (swt) has been assigned a 16 element array to determine which number is selected. How would I access that data?
When I try *swt, I recieved error messages and warnings. When I use swt[0-16], I get zeroes as the switch values.
|
|
|
|
|
Without actually seeing your code and if you are using
swt[0-16]
Then the actual index into the array is -16.
Larry J. Siddens
|
|
|
|
|
Original code looks like this:
if (local->decode)
{
swt[0] = 0;
swt[1] = 1;
swt[2] = 1;
swt[3] = 1;
up to [15]
}
locals->temp = 0;
for (mode_index = 0; mode_index < 16; mode_index++)
{
if (swt[mode_index] == 1)
{
locals->temp += (1 << mode_index);
}
}
====================================
What I am attempting to do looks like this where I tried *swt and swt[0], swt[1], swt[2], etc...:
nom3as = nim3as
if (nom3as == 0)
nom3ac = 0;
else
nom3as |= 0x00002000;
nom3ac = swt;
|
|
|
|
|
In your last line:
nom3ac = swt;
You're setting the variable nom3ac to the address of the start of the array (or the address of swt[0].)
Is this correct?
Larry J. Siddens
|
|
|
|
|
|
What about a good C language tutorial?
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]
|
|
|
|
|
You can use only integral expressions as the switch expression.
What type of array is it?
If it is a character array, you must use the string functions in the if statement.
If it is an integral array, you are storing multiple values. You must use the array subscript [] to specify which element to check.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I tried using [].
Will I have to use it for each element of the array?
|
|
|
|
|
Yes.
Say you have an array:
int p[] = { 5, 4, 3, 2, 1 };
then to get the 3rd element use:
int x = p[2];
This will set x to 3. Remember, arrays start at index 0 instead of 1.
To loop through
for( int 1 = 0; i < 5; i++ ) {
x = p[i];
}
Larry J. Siddens
|
|
|
|
|
Yes. You will have 16 array elements ranging from swt[0] to swt[15]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi,
my VC++ 6.0 application calls my check_user_sp stored procedure that calls the sys.sp_helpuser system stored procedure:
-----
CREATE PROCEDURE check_user_sp
@inp_user VARCHAR(20)
AS
EXEC sp_helpuser @inp_user
-----
I have no problem running the application against database on the 2000 sql server(2000 - 8.00.760), but I get 'Invalid character value for cast specification' error with the same database on the 2005 sql server(2005 - 9.00.1399.06).
the sp_helpuser is dated 1996/08/14 10:33 on both 2000 and 2005 server, and I don't get error when exec my get_user_sp in the 2005 sql server management studio.
what is 2005 sql server doing to cause this?
THANKING FOR YOUR HELP!
|
|
|
|
|
Hello!
try checking database collation settings / server collation settings.
|
|
|
|
|
thanks! I checked and they have the same collation seetings.
I looked into the sp_helpuser code and then realized that the one in sql server 2005 returns 7 columns but the one in sql server 2000 returns 6. My application expects 6 columns and gets the error with sql server 2005.
|
|
|
|
|
Hi,
I am sort of familiar with the functions:
GetPrivateProfileString()
WritePrivateProfileString()
used with parsing a .INI file.
What I want to do is get/set the Section names within a .INI file.
For example, if I had the .INI file
[c:\root\database\images\country.dat]
value1=1
value2=1024
value3=500
[FILENAMES]
0=c:\imagery\color\map1.jpg
1=c:\imagery\topology\elevation.dat
[c:\imagery\color\map1.jpg]
MapValue1=1
MapValue2=255:255:255
[c:\imagery\topology\elevation.dat]
TopologyData1=0
TopologyData2=1000
How can I dynamically access the Section names, within the brackets [ ], when I don't know what they could contain? AND can I change these (like re-path) and then update the .INI file?
Thank you.
|
|
|
|
|
|
That looks to be exactly what I need, half of it anyways. The other half is modifying/writing back these section names.
Thanks a million!
|
|
|
|
|
john john mackey wrote:
What I want to do is get/set the Section names within a .INI file.
Use GetPrivateProfileString(NULL, ...) .
"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
|
|
|
|