Search found 34 matches
- Fri Nov 07, 2008 5:20 pm
- Forum: Programming Discussion
- Topic: Something that might help you.
- Replies: 7
- Views: 1177
Re: Something that might help you.
Here's an adaption of your code with basically the same functionality, except that it doesn't include the 2nd if statement and returns a char * instead of an index. char * findSTR(char * needle, char * haystack) { for(; *haystack; haystack++) { int i = 0; while(needle[i] == haystack[i]) { if(needle[...
- Wed Nov 05, 2008 5:12 pm
- Forum: Programming Discussion
- Topic: C Challenge #1
- Replies: 7
- Views: 974
Re: C Challenge #1
Ah yes that's pretty much what I had in mind, except for the mistake I made with passing 0 instead of (char*)NULL.
- Wed Nov 05, 2008 4:44 pm
- Forum: Programming Discussion
- Topic: C Challenge #1
- Replies: 7
- Views: 974
Re: C Challenge #1
Unless you're using an entirely different mechanism I don't see how that would work. The documentation for the va_arg function states the following: Notice also that va_arg does not determine either whether the retrieved argument is the last argument passed to the function (or even if it is an eleme...
- Wed Nov 05, 2008 4:06 pm
- Forum: Programming Discussion
- Topic: C Challenge #1
- Replies: 7
- Views: 974
Re: C Challenge #1
This was a pretty interesting 'challenge', I knew how printf worked but had never created a function like this before... I'd like to know what your approach to something like this would be, if it's any different at all. Here's the code: #include <stdarg.h> //va_list etc.. #include <stdio.h> //printf...