|
Thank you!
|
|
|
|
|
First, because there is so much C/C++ code out there still running. With C/C++, there is no translation layer and it is true compiled code where some are interpreted. Sure you can get compilers for Java and VB that will create native code but you also lose portability, the reason for Java in the first place.
With C/C++, you have access to everything. This isn't a big problem for application developers but for driver programmers, it is a huge issue. C/C++ is also easier to write drivers than assembly.
But then, what does it really matter if C/C++ hasn't been killed off with Java, VB.NET, C#, SmallTalk, and others? If you don't need it, don't worry but they are good tools to have in the tool chest.
You do have to be careful with memory use. There is no garbage collector to save you so if you allocate it, you have to release it. This control is a huge asset but you do have to know how to use it properly. I like using C/C++ because I am most familiar with them. The other thing is I've gotten so I prefer the total control I have.
|
|
|
|
|
Why shouldn't the industry still use it? If it worked for them in the past, and they already have the programmers experienced in its use, why take the risk and switch to something else?
And besides, in many areas it still makes sense to use C/C++ rather than presumably more advanced languages:
1. Existing low level drivers are mostly written in C, and when adding a new driver it would needlessly complicate the interfaces and introduce additional sources of errors.
2. Similarly, Unix and Linux related OSs are written in C/C++, and writing any OS extension in another language would just complicate matters needlessly.
3. Embedded devices usually have much less resources available (processor, memory capacity), and there may only be a limited amount of compilers available for the OS being used. This makes languages like C/C++ a more attractive choice, as they can better deal with these conditions than some modern languages that were designed with the resources and OS-functionality of a full-fledged workstation in mind. E. g. you won't usually find .NET on embedded devices.
4. Real time applications often require full control of algorithms for time critical functions. Modern languages that rely on libraries or provide their own implementation of certain functions don't easily allow that kind of low-level control. Pretty much any language that provides garbage collection is a big no-no for real time, as you cannot sufficiently control when garbage collection occurs. Also, any language that does not use pointers can not be as efficient as a language that does. (or at least I wouldn't know how that's possible)
5. Any application that does an amount of local processing sufficient to make the users wait for more than a couple of seconds, can benefit from a language that allows for better performance. As pointed out in 4., languages not using pointers, or implementing garbage collection, may be inferior choices.
There are lots of examples where the benfits of C/C++ don't shine, e. g. a browser, or just about any web application benefits much more from libraries and even basic functionality that other languages like Java, PHP, Ruby etc. provide, and don't have any real restrictions regarding resources or performance. This is not my area of expertise though.
Personally I believe that beyond the above reasons, companies may stick with C/C++ simply because it works, and they are reluctant to switch to something new when all (or most) their programmers are used to C/C++.
|
|
|
|
|
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.
|
|
|
|