|
There was hardly any project/assignment in which I used templates. I just asked it.
|
|
|
|
|
overloaded Name wrote: how can I know that this is good to implement it or not??
Experience and failure more than success itself will tell you that using a language feature will be beneficial to your project.
why not success ? because at some point you will use one feature on the based of false previous success in a situation where it will fail miserably and you will need to re-evaluate your notions about that feature.
Anyway, good luck with it, it's always fun (when possible) to learn new features.
Watched code never compiles.
|
|
|
|
|
Read, lots. Try out different things. Make sure you've got a shelf load of C++ morality guides to back you up ("Effective C++" and "Exceptional C++" are good places to start).
As you try things out you'll find out if it's a good idea as your projects get bigger. For example extensive use of templates can slow the compiler down to a crawl. It's not a problem with 10 source files but with a couple of hundred it can be time for a tea break when you change one. Remember that language features in isolation rarely make that much of a difference to coding style (except perhaps for virtual functions, templates and exceptions) but when used together they can help and hinder a lot more.
Cheers,
Ash
|
|
|
|
|
Hi all,
i m using this to get edit box data line by line but here CEdit::GetLine return blank value when LineLength is 1.
CString strText, strLine;
for (i=0; i < nLineCount; i++)
{
int len = m_myEdit.LineLength(m_myEdit.LineIndex(i));
m_myEdit.GetLine(i, strText.GetBuffer(len), len);
strText.ReleaseBuffer(len);
strLine.Format(_T("line %d: '%s'\n"), i, strText);
}
please help me for this.
thank in advance.
|
|
|
|
|
You should make use of the return value from the function (see here[^]), and inspect the contents of your buffer if it only returns one byte.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Le@rner wrote: int len = m_myEdit.LineLength(m_myEdit.LineIndex(i));
Try:
int len = m_myEdit.LineLength(i);
...
strText.ReleaseBuffer();
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
hi all,
i want to create thread pool in my application.
please help me how can i do this.
please me any suggestion and example for it.
thanks in advance.
|
|
|
|
|
See Thread Pool API[^]. I used QueueUserWorkItem()[^] to add work items. That's because I was working on Windows XP. But I assume that there are better things to do (see the "current api" column on the first link page) if you are using Vista or above.
There are some really weird people on this planet - MIM.
|
|
|
|
|
|
Hi all,
I am making a sdi application in which i am making various tasks. All tasks are performing a single operation. Now my problem is i want that all the task should start at the same time. One more thing i have to Repetitively
perform that operation from my task.
Now i am not getting what method to use. Either i should use thread pooling or some other technique.
|
|
|
|
|
learningvisualc wrote: Now my problem is i want that all the task should start at the same time.
How can such a thing be done? Even if we have a quad core processor, and each execute one thread at a time independent of each other, then your most optimistic chances are to start 4 such tasks at the same time.
May be you should explain your requirements a bit more clearly.
There are some really weird people on this planet - MIM.
|
|
|
|
|
Does anyone know how (from C/C++) check if an EXE file is code signed / digitally signed? And how to get the company name that has signed the file?
I need to create a function (in C/C++) that starts an EXE file with a known filename, but for security reasons I must first check that this is the original file (check that nobody has replaced the file with another one with same filename).
I know how to get version information from an EXE file, but reading code signing info will make the function much safer.
|
|
|
|
|
Can't you instead generate an MD5 hash code from the exe and check that against a valid value to see if the exe was replaced or not?
Anyways, a little googling brought me to this[^], i guess you can go on from there...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Friday, October 15, 2010 4:20 PM
|
|
|
|
|
Thank you for your link. I think this will solve my problem. I will take a closer look.
|
|
|
|
|
Yourwelcome.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
I have "abcdefghigklmnop" and I want to insert "123456789" after 'd' for example. How can I do it?
|
|
|
|
|
Create a new array and copy the three pieces into it in the required order. A few simple strXXX functions should do the job.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I know this, but which functions is the question
|
|
|
|
|
if (laziness > selfEsteem) failAtEverything();
|
|
|
|
|
Take a look here[^] to get you started; you should get used to using MSDN if you wish to develop your skills in Windows programming.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi everyone, I have a program that reads ID3 tag information from mp3 file which is working. For ID3v1 tags, the track title starts at the 4th byte after the address of the TAG.
For some files I have encountered, the address where I expect the track title begins with the ASCII character code 0x20 which is a space, and there could be more of the spaces followed by the text. String copying becomes successfull only that the string begins with spaces and there is no problem.
Now the problem is that some of the mp3 files have spaces at the address where I expect the track title followed by garbage. I used a hex editor to view the bytes and I saw that the spaces were followed by garbage. This to me means there is no track title.
I want to know how I can detect this to avoid showing this garbage as the track title, or any other text I want since string copying uses the '\0' character to determine the end of the string. I used 'strncpy()' function in copying text.
|
|
|
|
|
I read about the ID3 tag format here[^], it says Strings are either space- or zero-padded. Unset string entries are filled using an empty string. , i guess this explains the space(s). However, it says that unset strings should be empty. So i guess when you see garbage it's either in a different encoding (no idea, like japanese characters or something), or the creator of the ID3 simply didn't bother following the specifications. If this later is the case, i doubt there is much you can do. Does any other player show the garbage also?
Could it be that the file contains more versions (or a different verision) of ID3 or has an extended tag ("TAG+") and only the "newest" tag contains the actual information and the rest is just "placeholder" with garbage?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Friday, October 15, 2010 11:28 AM
|
|
|
|
|
I checked again with a hex editor. The file contains 'TAG' beginning at the last 128 bytes. I am considering checking about 2 or 3 bytes where I expect the text and if they are all spaces, then I assume there is no text for what I was looking for. On Windows XP which I am using, viewing the summary properties of the file does not show the text for the track title which, viewing with a hex editor, begins with some spaces before some strange characters. That's why I want to try this approach. But I wish there is a better approach than this.
|
|
|
|
|
Can't a space (or zero character) at the very first position of the title mean it is empty? From your original post i gathered that sometimes there are spaces before the title but am not sure anymore. Is it possible that even when you see this case, i mean a space and then a title, that the title is actually just something that was in memory at the time the ID3 tag was written but because it starts with space it means that the rest of the string shouldn't be considered valid?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Code-o-mat wrote: From your original post i gathered that sometimes there are spaces before the title but am not sure anymore.
I even wondered about this, but I have realised that once the beginning bytes are set to spaces, they are unset. But the problem was that I used strlen() to get the length of the text for the track title.
Meanwhile, this function uses the '\0' character to detect when to stop counting and therefore counted spaces as well. Then I called strncpy() to copy string of text of the number returned by strlen(). This was causing those garbage to be copied as well.
I have written my own function that returns the length of a string, and I wrote it such that it will used both the '\0' and the ' ' (space) characters to detect when to stop counting. Thanks for your guidance, I really appreciate it.
|
|
|
|