![]() |
[C] Help with conversion
The problem I'm trying to solve, involves writing a function named convertToBinaryVersionA that will allow a user to enter a string, and convert the string to a binary string.
So for instance, my ouput would look like the following: Enter a string: 010011001 010011001 is convertible! or Enter a string: ^^^^010011001 010011001 is convertible! ^= denotes a user hitting the spacebar or Enter a string: 010011001^^^^ 010011001 is convertible! ^= denotes a user hitting the spacebar Enter a string: abc01010 abc01010 is not convertible! So far, this what I have, I haven't actually worked out how to ignore spaces before or after a string. Can anyone give me a hint on what I should do? Code:
#include<stdio.h> |
trim! i don't remember the syntax but the function trim will remove leading and trailing spaces for you.
|
I've never heard of trim before, but it sounds like its exactly what I need.
|
pure C does not have a trim function. You just need another else if conditional to handle the space. Currently you're program thinks its an invalid character.
|
All times are GMT -8. The time now is 10:11 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project