31
C/C++ & Visual C++ / C SOME UTILITY functions ...
« on: May 27, 2013, 01:27:36 AM »
This space is reserved for code and links to code for C utility functions ...
After I have collected several C snippets here ... I hope to make an index with links on this front page.
But for now, please find these little snippets of code below, (perhaps in related usage groupings of code, on the following pages.)
You may also like to see: C++ SOME UTILITY functions ...
http://developers-heaven.net/forum/index.php/topic,2611.0.html
Update 2015-04-08:
SEE the next link for several newly improved STUDENT take in type utilities ...
with out of bounds error handling ...
(Some VERY HANDY student utilities.)
http://developers-heaven.net/forum/index.php/topic,2608.msg3158.html#msg3158
1. /* example of a way to fix fgets TWO sometimes very annoying problems */
char* fixedFgets( char* str, size_t bufSize, FILE* fin );
2. /* example of a way to trim leading and trailing ws ... */
char* stripWS( char* s );
3. /* example of an expedient way in C to handle string input from keyboard operator ...
especially, if design calls to repeat input until string is of 'acceptable length' */
char* takeInStr( const char* msg, char* buf, unsigned bufLen, unsigned maxStrLen );
4. /* an example of a common design request ... to Caps on first letters */
char* toCapsOnFirstLets( char* str );
5. /* a simple student way to handle numeric input ...
so program won't crash on bad input */
int takeInInt( const char* msg, int myMin, int myMax );
6. /* loop until user takes in a valid int ... after prompt(s) ... */
int takeInValidInt( const char prompt[] );
7. /* a handy utility for many C student coding problems ... */
char takeInChar( const char* msg );
8. int more(); /* defaults to 'true'/'yes'/'1' ... unless 'n' or 'N' entered */
9. /* since using 'static' buf inside, memory persists ... so can return address */
char* takeInStaticString( const char* msg, unsigned max_len );
10. /* accepts only positive (i.e. >= 0) valid int range of values ... */
int takeInValidPosIntViaStaticString( const char* prompt, int high );
11. /* returns a valid int in range INT_MIN..INT_MAX */
int takeInValidMinMaxIntViaStaticString( const char* prompt, int myMin, int myMax );
...
And more added below ... like binary search, an iterative and also a recursive example, date and time and valid date and valid dob and days between two dates and ...
1. Six Fast Steps to Programming in C
http://developers-heaven.net/forum/index.php/topic,2022.0.html
2. CvecOfInt.h, CvecOfString.h, Cvec.h, Cvec_func's.h (with FUNCTION POINTERS)
http://developers-heaven.net/forum/index.php/topic,2580.0.html
3. Cvec_func's.h example programs ... using FUNCTION POINTERS to facilitate reuse
http://developers-heaven.net/forum/index.php/topic,2581.0.html
4. ClistOfInt.h, ClistOfString.h, Clist.h, Clist_func's.h (with FUNCTION POINTERS)
http://developers-heaven.net/forum/index.php/topic,2582.0.html
5. Clist_func's.h example programs ... using FUNCTION POINTERS to facilitate reuse
http://developers-heaven.net/forum/index.php/topic,2583.0.html
6. split.h ... a C emulation of the Python spilt function to parse a string ...
http://developers-heaven.net/forum/index.php/topic,2584.0.html
7. Binary Search Tree template class in C ++ and Simple C Version
http://developers-heaven.net/forum/index.php/topic,2605.0.html
8. Beyond Beginning Computer Programming in C ...
http://developers-heaven.net/forum/index.php/topic,2598.0.html
9. Send in your C++ or C student coding problem, with code inside code tags (#)
http://developers-heaven.net/forum/index.php/topic,2473.0.html
10. Free coding help for beginners in C or C++
http://developers-heaven.net/forum/index.php/topic,2575.0.html
11. Clist Insertion Sort Tutorial ... and also see a recursive merge sort of a list
http://developers-heaven.net/forum/index.php/topic,2440.0.html
12. First steps ... via example programs in C++ and C ...
http://developers-heaven.net/forum/index.php/topic,134.0.html
13. New thread especially for students of C and C++
http://developers-heaven.net/forum/index.php/topic,106.0.html
14. BEGINNING COMPUTER PROGRAMMING (using C++ or C)
http://developers-heaven.net/forum/index.php/topic,127.0.html
After I have collected several C snippets here ... I hope to make an index with links on this front page.
But for now, please find these little snippets of code below, (perhaps in related usage groupings of code, on the following pages.)
Update: please see this next link:
http://developers-heaven.net/forum/index.php/topic,2636.0.html
FREE homework help NOW available ...
You can contact me via:
http://sites.google.com/site/andeveryeyeshallseehim/home/he-comes
http://developers-heaven.net/forum/index.php/topic,2587.0.html
http://developers-heaven.net/forum/index.php/topic,2636.0.html
FREE homework help NOW available ...
You can contact me via:
http://sites.google.com/site/andeveryeyeshallseehim/home/he-comes
http://developers-heaven.net/forum/index.php/topic,2587.0.html
You may also like to see: C++ SOME UTILITY functions ...
http://developers-heaven.net/forum/index.php/topic,2611.0.html
Update 2015-04-08:
SEE the next link for several newly improved STUDENT take in type utilities ...
with out of bounds error handling ...
(Some VERY HANDY student utilities.)
http://developers-heaven.net/forum/index.php/topic,2608.msg3158.html#msg3158
1. /* example of a way to fix fgets TWO sometimes very annoying problems */
char* fixedFgets( char* str, size_t bufSize, FILE* fin );
2. /* example of a way to trim leading and trailing ws ... */
char* stripWS( char* s );
3. /* example of an expedient way in C to handle string input from keyboard operator ...
especially, if design calls to repeat input until string is of 'acceptable length' */
char* takeInStr( const char* msg, char* buf, unsigned bufLen, unsigned maxStrLen );
4. /* an example of a common design request ... to Caps on first letters */
char* toCapsOnFirstLets( char* str );
5. /* a simple student way to handle numeric input ...
so program won't crash on bad input */
int takeInInt( const char* msg, int myMin, int myMax );
6. /* loop until user takes in a valid int ... after prompt(s) ... */
int takeInValidInt( const char prompt[] );
7. /* a handy utility for many C student coding problems ... */
char takeInChar( const char* msg );
8. int more(); /* defaults to 'true'/'yes'/'1' ... unless 'n' or 'N' entered */
9. /* since using 'static' buf inside, memory persists ... so can return address */
char* takeInStaticString( const char* msg, unsigned max_len );
10. /* accepts only positive (i.e. >= 0) valid int range of values ... */
int takeInValidPosIntViaStaticString( const char* prompt, int high );
11. /* returns a valid int in range INT_MIN..INT_MAX */
int takeInValidMinMaxIntViaStaticString( const char* prompt, int myMin, int myMax );
...
And more added below ... like binary search, an iterative and also a recursive example, date and time and valid date and valid dob and days between two dates and ...
Code: [Select]
/* returns 'int' value if in range '0'..'9' else returns -1 if NOT a digit */
int getDigit( char c )
{
if ( c < '0' || c > '9' ) return -1;
return c - '0';
}
/*
Note: int( c ), where c is a char in the range '0'..'9'
would return integers in the range 48..57
... but getDigit( c ) returns integers in the range 0..9
*/
Code: [Select]
/* returns int value if in range '0'..'9' else returns -1 if not a number */
int isNum( char c )
{
if ( c < '0' || c > '9' ) return -1;
return c - '0';
}
1. Six Fast Steps to Programming in C
http://developers-heaven.net/forum/index.php/topic,2022.0.html
2. CvecOfInt.h, CvecOfString.h, Cvec.h, Cvec_func's.h (with FUNCTION POINTERS)
http://developers-heaven.net/forum/index.php/topic,2580.0.html
3. Cvec_func's.h example programs ... using FUNCTION POINTERS to facilitate reuse
http://developers-heaven.net/forum/index.php/topic,2581.0.html
4. ClistOfInt.h, ClistOfString.h, Clist.h, Clist_func's.h (with FUNCTION POINTERS)
http://developers-heaven.net/forum/index.php/topic,2582.0.html
5. Clist_func's.h example programs ... using FUNCTION POINTERS to facilitate reuse
http://developers-heaven.net/forum/index.php/topic,2583.0.html
6. split.h ... a C emulation of the Python spilt function to parse a string ...
http://developers-heaven.net/forum/index.php/topic,2584.0.html
7. Binary Search Tree template class in C ++ and Simple C Version
http://developers-heaven.net/forum/index.php/topic,2605.0.html
8. Beyond Beginning Computer Programming in C ...
http://developers-heaven.net/forum/index.php/topic,2598.0.html
9. Send in your C++ or C student coding problem, with code inside code tags (#)
http://developers-heaven.net/forum/index.php/topic,2473.0.html
10. Free coding help for beginners in C or C++
http://developers-heaven.net/forum/index.php/topic,2575.0.html
11. Clist Insertion Sort Tutorial ... and also see a recursive merge sort of a list
http://developers-heaven.net/forum/index.php/topic,2440.0.html
12. First steps ... via example programs in C++ and C ...
http://developers-heaven.net/forum/index.php/topic,134.0.html
13. New thread especially for students of C and C++
http://developers-heaven.net/forum/index.php/topic,106.0.html
14. BEGINNING COMPUTER PROGRAMMING (using C++ or C)
http://developers-heaven.net/forum/index.php/topic,127.0.html