|
One programming language is not better than other. Use the right tool for the right job.
PS: Note that ANYTHING is better than JAVA though. This is an exception.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
One programming language, but C, is not better than other.
FFY
Veni, vidi, vici.
|
|
|
|
|
1. Compatibility. If you want code to run on different architectures (X86, ARM, PIC, etc) and different operating systems, C (and sometimes C++) is the only way to go.
2. Performance. Predictable, excelent performance. Unrestricted use of memory and system resources.
3. Libraries (GLib, STL, etc).
4. Huge codebases.
5. Games (most games are done in C++).
6. Flexibility. C++ for example, doesn't impose "objects" and "interfaces". You can write code "the way you want" mixing objects, procedures and templates. You can write abstract code or go directly to asm in the same project.
C tops in portability. C++ tops in flexibility.
In these areas they have little competition (if any).
Both usually top in performance (there are exceptions, but they are that, exceptions).
That said, they are complex and require discipline. They are error prone. They are difficult to master (years). They don't have "unique" GUI or libraries. They are not controlled or improved by any corporation.
They move at slow pace, considering that improvements should not break existing software.
it´s the journey, not the destination that matters
|
|
|
|
|
I'm looking for an SDK that will make it easier for me to record audio and store it in one of the ADPCM variants like G.711, G.726, G.722, and others.
I am writing a recording utility for our application. The reason for using these encoding codecs are because they are more naively used for VOIP and can be used directly rather than standard PCM recordings to have to be converted first.
Key needs are being able to either directly record into this format or easily convert the recordings using API calls. Also a method to have the software automatically trim leading and trailing "silence". I quote silence because there is actually background noise but at a very low volume what would need to be trimmed. Having a way for the software to automatically trim this static of the beginning and end of a recording is a key feature for me. I don't want to have the user to use another tool to self edit the audio file because most of our users will not be efficient and will save the files in the wrong formats.
|
|
|
|
|
How to know whether the server has no data while reading the response of a request which is keep alive because the socket read function waits for the server to send data if we have made a request with keep alive option.
I am writing a socket program to fetch a webpage.
My request header has no connection close header so by default the connection is keep alive.
I open a connection, send the request header using socket_write and getting using a while loop to receive data
if it is a Connection Close request the everything works well.
if it is keep alive and after i have read the content the socket_read function is still waiting for data which causes the code to hand in there.
Here how do we know whether the server has completed sending the resource though it is keep alive...
i have a work around like checking the content-length response header to know how much data is received and accordingly i can stop reading
or
if response header has transfer-encoding as chunked then i can write more code to find the end of the response
yet without the above two workarounds how to check whether the socket_recv is still waiting for data?
Besides, i was thinking that since we are setting the read buffer length (like 1024 in this code) and the socket_recv is returning the no of bytes read and if the bytes read is less than 1024 then i can assume that the next read will not return anything and by this time i can quit the while loop.... BUT http server sends different length response so my logic will not work.
Here is my request header and the while loop in which i receive date from the server
//i have commented the connection close header so that by default it will be keep alive
here the code is in different language but the basic concept is the same for all languages so i am asking it here.
$o = 'GET /search?hl=en&q='.$query.'&start='.$start.' HTTP/1.1'."\r\n";
$o.= 'Host: www.google.co.in'."\r\n";
$o.= 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0'."\r\n";
$o.= "\r\n";
do
{
$bytes = socket_recv($f, $tbuf, 1024, 0x40);
if($bytes === false)
die("\r\nUnable to read headers - ".socket_strerror(socket_last_error()));
echo "\r\n".$bytes;
if(!$bytes)break;
$buf.= $tbuf;
}while(1);
In the above code after i have received the complete html of a webpage the control is in the line where i am reading the response. Which i assume the code is still waiting for data from the server.
Suggestions, comments and advice's are welcome.
|
|
|
|
|
You have been here long enough that you should know to ask your questions exactly ONCE.
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I will delete the other one
|
|
|
|
|
Since you are using blocking sockets (and not async sockets) you have to find out the size of the response and read exactly that many bytes from the socket. If its chunked encoding then you have to read till the end.
Blocking mode sockets with raw api calls work like this: When you send() data the send() function returns only if an error occurs or the whole buffer you provided could be written out the send buffer of the socket. recv() works a little bit different, it returns immediately even if only a single byte of data is available in the receive buffer of the socket and you can't assume that a consequent recv() call would block if your buffer wasn't filled up completely during the previous call. This behaviour of recv() can be changed to wait for a whole buffer by specifying the MSG_WAITALL flag on windows but that is not recommended and that flag isn't supported everwhere.
|
|
|
|
|
oh... let me try the async (non blocking)...
Besides, yes as you have suggested it is that i have to read untill the end chunk by chunk...
I will try both. Thank you for the reply.
http://vikku.info/ Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
|
Hi,
can anyone please tell me how to select the multiple items in
the tree control using Non MFC code
i searched on google i got the following but it is used with MFC
i want it in Win32, if anyone have idea about this please reply
http://www.codeguru.com/cpp/controls/treeview/misc-advanced/article.php/c629/A-multiselect-tree-control-class.htm
thanks
|
|
|
|
|
According to the documentation[^] mult-select is not supported. You would probably need to use subclassing[^] to achieve this.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
but i am using win32,
how to do this?
is do u have an idea.
|
|
|
|
|
Ram Shelke wrote: do u have an idea. Yes, and I gave it to you in my previous answer. You need to subclass the control and add your own code to make multi-select work.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
As Richard has pointed out, there is no support for multi selection for a tree control, so it is something that has to be added on your own. However from his link to the documentation, there is another link to an article that suggest with Windows Vista and onward, there is support for multi selection on a tree control. Check out this link and see if it helps you to get started. Windows Vista Control Enhancements[^]
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Interesting that the article was written in 2007, and yet the link I found claims to be current as of 2012.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
That documentation was rated down and that might be part of the reason. Though there is no mention if the Vista control enhancements ever made it back into the main stream, like Win 7 or 8.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Hi
I have tried to use a method from long ago:
http://beta.codeproject.com/Articles/358/Avoiding-Multiple-Instances-of-an-Application
BOOL CMyApp::InitApplication()
{
// there can be only one instance of this application, that is per windows user logon session!...?
if(::CreateMutex(NULL,FALSE,_T("{9C114FA0-0D7A-4e3f-8195-BE59EFC3EA42}"))==NULL)
return FALSE;
if(::GetLastError()==ERROR_ALREADY_EXISTS || ::GetLastError()==ERROR_ACCESS_DENIED)
return FALSE;
return CWinApp::InitApplication();
}
Simultaneous users can still create an instance each. Why is that? Do anyone have an (easy) solution?
Using Windows XP SP3 with VC 6.0.
Thanks!...?
|
|
|
|
|
With Windows 2000 and later, you should prefix the name with 'Global\' to create it in the global name space:
::CreateMutex(NULL,FALSE,_T("Global\\{9C114FA0-0D7A-4e3f-8195-BE59EFC3EA42}")
Then the call will also fail for other users.
|
|
|
|
|
You need an additional part which will solve it. Your application should check if other instances if it are running (by checking all running processes) and if so, terminate itself. You can set up rules as of who should quit and who should continue (for example, if an outdated version is running and another newer version starts, then the older version should quit, like in my article about auto update Target Eye Revealed part 1 - Target Eye's Unique AutoUpdate Mechanism[^]).
|
|
|
|
|
Hi all,
is there a way, in C++, to correctly recognize a table in a pdf file and extract its data laid out in rows and columns?
I think a possible solution could be extract tables from pdf to excel (using one of the tools available) and then reading data from excel files.
But is this the proper way ? Are there any other solutions ? Is there a library (free or commercial) that can help me ?
Thanks in advance for your help
Luigi
|
|
|
|
|
As a matter of fact there is no PDF way to determine a table in a pdf. because there is no table type object in PDF file. But with clever programming you can determine if there is any table. but yet that wont be simple task and might not be correct all the time.
I wish I could believe there is an after life.
|
|
|
|
|
I am trying do a coding in c++ and My problem goes something like this. I have a variable of 5 arrays a[5] for storing the 5nodes of a network. The network is randomly formed by the random number generator. I have the time of travel for each paths of the network. All the nodes may not be connected to eachother. The network and the time of travel of each path is as per the user has assigned. Now I have to check the elements of each array and assign the penalty as per the conditions. My main task is to find a network path traveling each node of the network only once such that the node visited is not repeated. Its similar to TSP but the difference is that in TSP has the condition that it is possible to travel from each node to every other node. But for my case the network is pre defined and nodes are not connected to every other nodes in the network.
a) Like if the network stored is 2-2-3-4-5 then I find that a[1]=a[2] so I will have to assign the penalty (type 1 )as the network has a path 2-2 which is not possible as the starting and end of the path is same. At the same time for rest of the paths from node 2 to 3, node 3 to 4, node 4 to 5 I will have to calculate the sum of total time of travel when I finally reach the node 5.
b) Also there is another penalty condition if the path is not a possible path in the network given by user then I will have to assign penaly( type 2) for such kind of condition like if 1-2-4-3-5 is a network to be checked. Here I am supposing that all the paths are possible but the path 4-3 doesn’t exist in the real network provided by the user, So for such cases I will have to calculate the sum of the time of travel for the paths which are possible and also assign the penalty (type 2)
c) There is also a condition that I need the end point of the network as node 5.So in the network generated randomly if the end node is not the node 5 then I will have to assign the penalty (type 3) and at the same time calculated the sum of the rest possible paths. For example the node 3-5-2-1-4 here the end node is 4 so I will have to assign the penalty(type 4)
d) Since I am not allowed to visit the same node twice I will have to assign the (penalty type 4) if the network has repeatition of nodes like if the network is 2-4-3-1-4. Here the node 4 is occurring twice so I will have to assign the penalty(type 4) and also calculate the sum of the time of travel of the other paths.
Considering all the above penalty conditions I will have to check the network s. I am really not being able to use any logic on how do I start. Need some hint on how do I do it.
modified 15-Sep-12 12:53pm.
|
|
|
|
|
This question may get a better response if posted in the Algorithms Forum[^], as it is not really specific to C/C++.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I need to create an array using a int variable who cant be a numeric const, because it represent a variable length of something.
So i need to use the code:
const int iLength = iVariable;
int x[iLength];
this code doesn´t work because the c++ allows me just:
(suppouse length 10)
#define 10
or
int x[10];
I do not to use resize array because would be slower
someone can help me ?
Thanks for your attention
|
|
|
|