Are there any functions fast than sccanf, sprintf, strlen?
-
Hello everyone: Are there any functions fast than sccanf, sprintf, strlen? Thanks. -Freehawk
Maybe. Before you start though I have two questions: Have you done a profile on your program and determined that you program is really spending a lot of time in those 3 functions. In most cases, despite those functions not being particularly good, they are good enough. Why are you not using a C++ string class, and the functions they provide to do the same? There are a number of them out there. Assuming you have good answers to those questions: strlen is best made faster by making a string class (or structure if you must do pure C) that holds the length of the string. Keeping this up to date can greatly speed up your program if strlen is called often. The other two are most easily taken care of by careful analysis of what you are doing with them. In most cases just knowing something about the data and how it is used can make solutions obvious. (for instance if you use sprintf to create a string, and sscanf to latter pull it apart, why create the string in the first place, just pass the data) Not knowing your data I cannot say more. I still suspect that this question is not worth asking.