|
Beside moving the start=clock() call to a more appropriate place as previously suggested, an old trick I learned in order to have reproducible test timings, always start your timing run on the beginning of a fresh clock tick.
clock_t start, end, tt;
tt = clock();
while ((start = clock()) == tt);
...begin timing test
end = clock();
Don't start the timing until you get a different answer from clock(), now you have a whole clock tick to work with.
|
|
|
|
|
here is my code-but i am getting segmentation fault???? any body help me???
programme aim is:to find a time consumed[taken] for sorting a given array
#include<stdio.h>
#include<time.h>
const int MAX=1000;
int partition(int a[],int low,int high)
{
int i,j,temp,key;
key=a[low];
i=low;
j=high+1;
while(i<=j&&key<=a[i])
{
i++;
}
while(key>a[j])
{
j--;
}
if(i<j)
{
temp=a[i],a[i]=a[j],a[j]=temp;
}
else
{
temp=a[low],a[low]=a[j],a[j]=a[low];
return j ;
}
}
void quick_sort(int a[],int low,int high)
{
int mid;
if(low<high)
{
mid=partition(a,low,high);
quick_sort(a,low,mid-1);
quick_sort(a,mid+1,high);
}
}
void main()
{
int a[MAX],n,i,start,end;
double CLK_TCK;
printf("enter the no of elements:");
scanf("%d",&n);
printf("\n enter the elements to sort\n");
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
start=clock();
quick_sort(a,0,n-1);
end=clock();
printf("n the sorted elemetns are:\n\n");
for(i=0;i<=n;i++)
printf("%d\t",a[i]);
printf("\n\n time consumed the array is: %5.2f sec: ",(end-start)/(double)CLK_TCK);
}
|
|
|
|
|
You might get more help if you posted it to the Quick Answers instead of a reply just to me.
I can tell you that if you do post it in Quick Answers, the first thing people will ask for is "more information". Just saying "segmentatation fault" is not enough to go on. "Where" might help. ALso, nobody is just going to run and debug it for you, we don't have the data, the time, or the inclimation to do all the work for you. You'll have to show some results of your own debugging first.
|
|
|
|
|
I'm using SHFileOperation and it works well, but I really need to know when it's done because I'm setting the file permissions for users right after, and just want to make sure the files and folders are really there first.
I'm just looking for some suggestions on this if any may exist.
PS
I did write something for IFileOperation, but I was only able to get a single file copy to work, and haven't figured how to build the file array list for multiple folders and files.
|
|
|
|
|
Isn't it done when it returns?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
I thought that was the case, Wasn't really sure during some test runs, it looked like it was running in it's own thread.
I guess as long as the results are correct, that's all that matters.
|
|
|
|
|
It most likely does run in a separate thread but it also probably waits until this thread is done (just guessing this). However, if you experience that right after the operation some files can't be accessed it might be that the thread didn't release open handles yet to them (e.g. it is still in the process of terminating or somesuch) you could implement somekind of timeout mechanism, you try to access the file and keep trying periodically with some delays inbetween until you either succeed or some preset time period has passed, if you couldn't perform the operation before the time expired, error.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
That's a great idea, and I must concur with the theory. I'll write some extra code to test for file release first, and then proceed.
Thanks.
|
|
|
|
|
Hi,
I have implemented primitive voice removal by following the link:
http://www.cdf.utoronto.ca/~csc209h/summer/a2/a2.html[^]
It works, but not for all files and the results are not very consistent.
Any ideas and links to an open source libraries (C/C++/C#/Java) that do that, will be much appreciated.
Thanks,
Yuval
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein
modified 15-Feb-12 12:05pm.
|
|
|
|
|
A good hard kick to the nadgers should keep them quiet for a while.
Software Zen: delete this;
|
|
|
|
|
OK, and how does this 'suggestion' help me with the problem?
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein
|
|
|
|
|
Sorry . When I posted my smart-ass reply, your message was in the Lounge. Good luck with your search.
Software Zen: delete this;
|
|
|
|
|
|
I want to let two client create TCP connection. These two clients are in different LAN, and there are firewalls, so these clients do not have WAN IP. But there is a server that these two client can visit.
Is there a way to create TCP connection between two clients through server?
|
|
|
|
|
TCP connections are based on the client-server concept. So two clients can not communicate even when in the same network segment.
It would be possible to create a special service that can pass through messages from one connected client to another one. But this requires a well-thought-out design of the protocol (identifying/addressing clients, keep-alive packets).
The usual way is to use port forwarding on the firewall / router to access servers behind. Other options are VLANs and tunneling.
|
|
|
|
|
Jochen Arndt wrote: TCP connections are based on the client-server concept. So two clients can not communicate even when in the same network segment.
Load of crap.
TCP is a non real time high quality protocol, it has sod all to do with clients and servers.
And can you open sockets between machines on the same sub net? Yes, you can. Regardless of which is a 'server'. (Define 'server'. Is it DHCP? Domain? File? How does the lack of installation of any number of 'server' components make a computer incapable of creating or accepting a socket connection?)
==============================
Nothing to say.
|
|
|
|
|
According to the subject the first part of my answer is about TCP connections, where a server listens on a socket and one or more clients can connect to the server.
The terms server and client are well defined in this context.
|
|
|
|
|
But you werent using client and server in that sense of a socket connection, you were using it in terms of network computers: "So two clients can not communicate even when in the same network segment."
==============================
Nothing to say.
|
|
|
|
|
Nit-pick.
A system that provides a service using a listening socket (or other methods) is a server. A system that connects to a server is a client. A system may be server and client at the same time.
|
|
|
|
|
Nit pick? You are talking crap saying you need a service to pass communicaitons on between machines on a network. You confused the socket and network terms for client and server and gave the OP the wrong answer.
==============================
Nothing to say.
|
|
|
|
|
You should let the OP decide how to treat my answer. Maybe you can help him by giving an applicable answer (ping does not help him because both systems are probably behind routers using NAT).
I confused nothing. I just have another view and understand that this view is not follwed by everyone. By accepting this view, there is no problem to understand what I have said. But claiming it as crap shows that you did not give at try.
EOD
|
|
|
|
|
Jochen Arndt wrote: both systems are probably behind routers using NAT
That is what we need to establish. If so, then he is into a more complex design. But it is possible that all he needs to do is open a few ports on the firewall.
OK, I admit, I reacted to the terminology you used, understanding it to mean something else so I will apologise for saying 'crap'.
==============================
Nothing to say.
|
|
|
|
|
Erudite_Eric wrote: That is what we need to establish. If so, then he is into a more complex design. But it is possible that all he needs to do is open a few ports on the firewall.
I think it has been already found out to be so. Opening ports may be not possible when prohibited by company policies. Because we did not know about the network topology that should be covered, the OP should give us more details. But may be he already decided what to do.
Erudite_Eric wrote: OK, I admit, I reacted to the terminology you used, understanding it to mean something else so I will apologise for saying 'crap'.
Thank you. I appreciate that.
|
|
|
|
|
Yes, he replied to me saying that he cant open ports "for some reason". If this is the case it seems like he isnt going to be able to get any custom TCP coms working.
==============================
Nothing to say.
|
|
|
|
|
Actually... I think you're wrong on this one.
|
|
|
|