|
I'm sure he knows that. His sentence is bound to the context, i.e. "you cannot allocate memory dynamically on the stack that way"
(I'm one of the 10 Rajesh's monkeys... )
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]
|
|
|
|
|
Yea i have writed
(...
int n;
cin >>n;
double a[n];
...)
earlyer, but didnt saved , now this works fine:
int main() {
int n;
cin >>n;
double a[n];
for(int i=0;i<n;i++){
cin >> a[i];
}
double sum;
int kiek;
kiek=0;
sum=0;
for(int i=0;i<n;i++) {
if (a[i]>0) {
sum=sum+a[i];
kiek=kiek+1;
}
}
if (kiek<1)
cout << "too few numbers";
else
cout<< sum/kiek;
return 0;
}
did i need to enter kiek and sum begining values, and if i leave them with no beginning values they are 0 or 1 ?
|
|
|
|
|
Why didn't you answer Rajesh's question?
How can the following code
zutautas wrote: int n;
cin >>n;
double a[n];
compile?
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]
|
|
|
|
|
its a part from all code...
...
int n;
cin >>n;
double a[n];
...
i dont know how you showing just few lines instead of all text, but i do it this way 
|
|
|
|
|
I show few lines that should NOT compile. I wonder why your compiler doesn't complain.
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]
|
|
|
|
|
My comment was in context with what the OP was trying to do there -- I had put the context within parenthesis in my previous post.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi everyone i m facing one problem while writing buffer into a file.
Actually i m using Ramanan T's NTFS undelete code for reading MFT table for files in
NTFS file system of a partition.
Undelete a file in NTFS
I m getting junk characters for small headers files of visual studio.Its reading all other formatted files like .doc,.xls or JPEG,.bmp etc properly.Even large sized cpp files also reading properly.i m reading 4kb ie one cluster at a time.
Here is the code where i m getting the junk characters.
class CErrorLog
{
public:
CErrorLog(void);
public:
Í ErrorLog(void);
WCHAR wcErrLogPath[QP_MAX_PATH];
}
I m not able to find out why that junk is coming in between for some files only
Thankx in advance for any help.....
|
|
|
|
|
Hi,
I have not looked at the source code at the link you provided. However I know from experience that small files under 1kb are not stored on a disk cluster on an NTFS disk. On a disk with a 4kb cluster size it would waste 3+ kilobytes. They are instead stored directly in the $MFT FRS segment. Check the source code and see if the author added special code for this sitation.
You should not trust that all source code you find on the internet is written correctly to handle all sitations.
Best Wishes,
-David Delaune
|
|
|
|
|
ya David ur absolutely right that i should not depend completely on the code,but as you had asked that is there is any special provision made in this code to handle Resident files which are stored in $MFT FRS.Yes there is but still same problem is coming.Out of 100 only 2 or 3 files are being getting corrupted.Actually i dont know how to read MFT table through data runs (by using VCN's & LCN's) thats why i m using that code .If u have any idea about reading MFT table please let me know ...........
|
|
|
|
|
I write a COM class in VC++ that is used in a .Net WebService as a refrence.
The COM object has an interface that simulates an IDispatch array to pass arrays of different objects to/from COM object.
I can pass that array to COM object in C# samples correctly, but when i pass it in C# webservice i get exception.
Can enyone help me?
Is there any limitation for WebServices in using COM objects
|
|
|
|
|
Hi all,
please tell me how can i get details of CPU and Memory usage that is used by my application.
please help me for ths.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: how can i get details of CPU and Memory usage that is used by my application.
See GetProcessTimes()[^]
What memory usage? The working set? If yes, then see GetProcessWorkingSetSize()[^].
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have a SDI type application in MFC.
I want to get information same like Window Task Manager display.
like My exe name is Test.exe
so in Processes Tab of Window Task Manager display the information like this.
Image Name="Test.exe"
User Name="";
CPU="07";
Memory="4,564K";
Description="Test";
Please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
|
Rajesh R Subramanian wrote: "_$h@nky_" wrote:
CPU="07";
Memory="4,564K";
Description="Test";
See Getting hardware information[^]
I m using this but i dont have information like i mention above.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
read(fd,buf,1) is so common that I do not need to explain its arguments.
Where can I find the source code for it?
|
|
|
|
|
read is a really common function you are correct so common we cant really determine what platform your on?!?!
i am guessing linux from unistd.h ??? if this is the case then you should have it on the machine already, in one of those ddep dark corners of the system.
|
|
|
|
|
Yes, Linux, C applications. I'm not looking for the header, I'm looking for the source code of the function.
Thanks.
-- frank
|
|
|
|
|
im saying that the .c file is on your PC...
i think that read just passes params down to syscall() if that helps
modified on Saturday, July 25, 2009 4:11 AM
|
|
|
|
|
342 asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
343 {
344 struct file *file;
345 ssize_t ret = -EBADF;
346 int fput_needed;
347
348 file = fget_light(fd, &fput_needed);
349 if (file) {
350 loff_t pos = file_pos_read(file);
351 ret = vfs_read(file, buf, count, &pos);
352 file_pos_write(file, pos);
353 fput_light(file, fput_needed);
354 }
355
356 return ret;
357 }
358 EXPORT_SYMBOL_GPL(sys_read);
found this snippet on interwebbs also http://www.gelato.unsw.edu.au/lxr/source/fs/read_write.c[^]
|
|
|
|
|
My MFC application needs to monitor a directory on a network disk (mapped as Z , and I'm using FindFirstChangeNotification() to do this. However, I am getting an INVALID_HANDLE_VALUE returned, and GetLastError() return 56 (which appears to be "The network BIOS command limit has been reached."
If I change the path of the monitored folder to a local drive, it works fine. How do I get over this problem ? (MSVC 6.0 - Win2000) (All the results from a Google search only seem to refer to a server situation)
Doug
|
|
|
|
|
can you post a code snippet or something to work with?
|
|
|
|
|
Here is the code in my worker thread, as requested:-
UINT WaitNewScheduleThread(LPVOID Param) //20090723
{
CWinThread* pThread = AfxGetThread();
int iID = pThread->m_nThreadID;
CString szLogMsg;
szLogMsg.Format("\n>>> Worker thread ID = 0x%X\n",iID);
OutputDebugString(szLogMsg);
CMCManagerBEDlg* pDlg = (CMCManagerBEDlg*)Param;
CMCManagerBEApp* pApp;
pApp = (CMCManagerBEApp*)AfxGetApp();
HANDLE hCN;
CString szPathName;
szPathName.Format("Z:\\WinDVR");
//szPathName.Format("C:\\Dell");
// Set up array of two handles
HANDLE hExitEvent;
hExitEvent = pApp->m_hExitEvent;
HANDLE handles[2];
int iRetCode;
DWORD dwRC;
DWORD err;
do
{
hCN = FindFirstChangeNotification(szPathName,FALSE,FILE_NOTIFY_CHANGE_FILE_NAME);
if(hCN == INVALID_HANDLE_VALUE)
err = GetLastError();
handles[0] = hCN;
handles[1] = pApp->m_hExitEvent;
dwRC = WaitForMultipleObjects(2,handles,FALSE,INFINITE);
if(dwRC == WAIT_OBJECT_0)
{
szLogMsg.Format("Found new file on %s",szPathName);
g_pLogFile->Add(szLogMsg);
OutputDebugString(szLogMsg);
if(g_pDlg->m_bPermitSchedUpdate)
g_pDlg->ProcessNewSchedule();
else
g_pDlg->m_bNewSchedAvailable = TRUE;
iRetCode = 0;
}
if(dwRC == WAIT_OBJECT_0 + 1)
{
szLogMsg.Format(">>> New recording schedule thread terminated\n");
OutputDebugString(szLogMsg);
g_pLogFile->Add(szLogMsg);
iRetCode = 9;
break;
}
if(dwRC == WAIT_FAILED)
{
szLogMsg.Format(">>> Wait failed");
OutputDebugString(szLogMsg);
}
}
while(TRUE);
return iRetCode;
}
Doug
|
|
|
|
|
so i think because your polling the call FindFirstChangeNotification() in an infinite loop it cries
might try adding a lil timer to the thread and put the contents of the do{}while(1) in the thread OnTimer event setting the polling interval to be something sensible
|
|
|
|
|
But the loop gets suspended at WaitOnMultipleObjects() after the very FIRST invocation of FindFirstChangeNotification(). (The whole reason for using this approach is to get away from a polling mechanism which introduces a delay) As I said originally, the code works fine when the target is a local disk - something to do with network, and I don't know how to fix it !!)
Doug
|
|
|
|