ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Not very robust? Optomize? If it doesn't even work I'd say optomization should be the last thing you should be worrying about. You're trying to dereference and increment a function. You're going to need to create another buffer.
Please use [ code ] tags. Quote me if you dont know how. You might also want to try using a COMPILER which will tell you this function doesn't work unless RmSymbols is some sort of global variable, and if thats the case why are you returning it. This isn't bash, you need to declare your variables before you use them.
Code:
char *RmSymbols ( const char *str ) {
char *ptr = str;
while (*ptr != '\0') {
if (*ptr >= 65 && *ptr <=90)
*RmSymbols++ = *ptr; /* what are you doing??? */
ptr++;
}
}
You got me. Sorry...I had been eating cake, so I wasn't looking for program corectness...more of a general idea. Plus, leaving bugs in would help him/her with debugging anyway.
Good catch w.r.t. strlen(), also. I should probably spend less time writing code while eating cake, I think
I suggest ditching 'str' since you really aren't using it in the first place. 'str' isn't byref so altering it wouldn't be a bad thing persay here... You can reduce the size of the code with increasing/reducing number figures around >= and <= to do the exact same thing only with > and <! Using the function name *( RmSymbols++ ), as a variable itself, is very indicative this guy is a Visual Basic user. As this is one feature to the language I would imagine is Microsoft's attempt at making people more dependent on their products.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.