|
Stephen Hewitt wrote: ... requires intelligence, which is something computers don't do well; they do dumb but fast.
A bit like some of the posters here ...
|
|
|
|
|
Hi there,
I got trouble with calling externals. Maybe somebody can help me.
I used to call external programs (exe-files) with the system() call. Now I want to start an external program in a seperate shell (and as a separate process). Can anybody tell me how to do that?
Thanks a lot.
Souldrift
|
|
|
|
|
call a batch file. In it can you create an own environment.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Use one of the exec()[^] calls. They create a separate process and also allow some communication with the parent.
|
|
|
|
|
Souldrift wrote: Can anybody tell me how to do that?
By reading here.
"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
|
|
|
|
|
Hi
Can i get column name from excel?
|
|
|
|
|
Davitor wrote: Can i get column name from excel?
What exactly do you mean; columns are fixed alphabetic identifiers starting at 'A'?
|
|
|
|
|
Are you referring to the range's GetName() method?
"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
|
|
|
|
|
I use file-manager to view property of my exe file, file-manager displays:
File size: | 3,401,216 bytes | File size on disk: | 3,403,776 bytes |
You see, sizes are different.
What do they exactly stand for?
What C functions are related or used for obtaining the sizes?
"File size" is from FindFirstFile(...) function - just tested.
But which function gets "Size on disk"?
modified on Thursday, October 1, 2009 6:22 AM
|
|
|
|
|
They mean exactly as labeled. The size of the file is 3,401,216 bytes but when it is stored on the disk it takes 3,403,776 bytes.
This is because you can allocate space from HDD only in blocks, for windows it is 4KB. So even if you create an empty text file it will still take 4KB on HDD.
-Saurabh
|
|
|
|
|
Fake info.
You try a empty txt file to see its "size on disk", which is 0.
I just tested.
|
|
|
|
|
How many clusters do you need to store 0 bytes?
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel] | FoldWithUs! | sighist
|
|
|
|
|
Well its not fake but slightly incorrect info. Trying adding a single character to file and see what happens. You know you can learn a lot but just experimenting yourself.
-Saurabh
|
|
|
|
|
Answer question or go away.
You need to learn how to comunicate with others, do not say the useless and meaningless sentence anywhere:
You know you can learn a lot but just experimenting yourself.
How about yourself?
|
|
|
|
|
Well I learn most of things by experimenting. And that sentence was not meaningless it had a very specific purpose and I think it served its purpose very well.
Fine this is my last reply to you. I am not getting paid to answer here, I like helping others.
-Saurabh
|
|
|
|
|
Actually, if the file system is NTFS, then really short files are completely contained in the MFT itself and do not take up any clusters outside of the MFT.
For some good info on file systems, download JkDefrag version 3.36 (the last open source version) and read both the commentary and the code.
Dave.
|
|
|
|
|
Thanks. I use JkDefrag, now MyDefrag, quite frequently but didnt knew its documentation has information about file system also.
-Saurabh
|
|
|
|
|
In NTFS, a very small file just gets stored in the directory entry. So the cluster size "problem" doesn't happen.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
File size is the amount of data you can read from the file, i.e. how many bytes ReadFile() would return. It is affected by WriteFile, SetFileSize etc.
The file size on disk is the amount of storage actually requried to hold the file. There are many factors affecting that:
Disk clusters - disks are allocated in clusters (e.g 4KB blocks). In thsi case, even a 5 byte file will occupy 4K on disk.
File System Compression
Sparse files - some file systems, like NTFS, allow "sparse files", where long runs of 0 data are not stored.
Alternate Data Streams - on some file systems such as NTFS, each file can contain multiple "data streams". The data you "expect" - like the text in a text file - is the default stream. MS uses alternate data streams e.g. to store document properties, the "this file was downloaded from the eeevil internet" flag etc. They are quite cool, but limited to file systems that support them.
Calculating these sizes is tricky.[^] As Raymond Chen notes, there is no straightforward API for that, because how to calculate the size largely depends on the reason why you need to know the size. (Backup storage amount? percentage of disk occupied? Should alternate streams be included? etc.)
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel] | FoldWithUs! | sighist
|
|
|
|
|
Your are right.
But, anyway, file-manager displayed "Size on disk", by what functions?
|
|
|
|
|
The value you see is calculated by the shell, but AFAIK the shell does not publish the algorithm it uses, nor does it expose a function giving you this information. The other reply is a good first shot at the value, but it's not guaranteed to be identical with what explorer shows.
Btw: replying to others with "Answer question or go away." gives yo ua good chance to get no answer at all.
This is a very rude and unfriendly reply, and it sounds like you are not interested in solving the problem yourself.
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel] | FoldWithUs! | sighist
|
|
|
|
|
includeh10 wrote: But which function gets "Size on disk"?
There are no standard API functions which return the storage allocation for a file on the disk. There are many variables which have an effect on file storage size. For standard non-compressed and non-sparse files you can calculate it something like this:
#include <sys\types.h>
#include <sys\stat.h>
__int64 GetFileSizeOnDisk(LPCTSTR szPath,LPCTSTR szDriveLetter)
{
struct _stat64 st;
DWORD dwClusterSize = 0;
DWORD dwSectorsPerCluster = 0;
DWORD dwBytesPerCluster =0;
GetDiskFreeSpace(szDriveLetter,&dwSectorsPerCluster,&dwClusterSize,NULL,NULL);
dwBytesPerCluster = dwClusterSize*dwSectorsPerCluster;
int err = _tstat64(szPath, &st);
return err != 0 ? LLONG_MIN : st.st_size+dwBytesPerCluster-st.st_size%dwBytesPerCluster;
}
Note that very tiny files on an NTFS partition which are less than 50% of 1 cluster have a high probability of being stored directly in the $MFT which makes the function above have no meaning. There may also be alternate file streams associated with the file which would technically also add to the total storage allocation. For a complete solution it should be possible to get all volume storage allocation by using the FSCTL_QUERY_ALLOCATED_RANGES[^] Control Code.
Best Wishes,
-David Delaune
|
|
|
|
|
Problem : To construct a C++ code from a given Visual Basic String.
Frontend Application : Visual Basic
Backend Application : C++
Example1:-
Given Argument Is: Visual Basic String:
if (S>K) then S-K else 0
Result Should Be: C++ Code:
if(S>K) return S-K; else return 0;
End of Example1.
Now, from above example we find that there is if..else condition as well as an expression into it. There may be a case where i may
have nested condition or some math functions into it.
Example2:
Given Argument Is: Visual Basic String:
if (S>(K*V)) then Exp(S)-Sqrt(K) else if(S<k) then="" k-s="" else="" 0
<b=""> Result Should Be: C++ Code:
if(S>(K*V))
return (exp(S)-sqrt(K));
else if(S<k)
return="" k-s
="" else
="" 0;
end="" of="" example2.=""
so,="" there="" may="" be="" any="" random="" vb="" string="" which="" need="" to="" converted="" into="" executable="" c++="" code.=""
<div="" class="ForumSig">Thanks & Regards
Vishrant Shah
|
|
|
|
|
Yes, that's a very nice homework problem. I think you have stated it very well. Let us know what you come up with.
|
|
|
|
|
Vishrant Shah wrote: So, there may be any random VB string which need to be converted into executable C++ code.
Do you want to convert the code only (meaning, not execute it) ? Or do you want to also execute it ? If you need to execute it, this gonna be a big problem because you need to compile the code first (you can't execute code on the fly).
|
|
|
|