Thread: Basic Doubt on Pointers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    Quote Originally Posted by rstanley View Post
    Perhaps you should check to see if it compiles and executes corectly, BEFORE posting an alleged solution to a user:
    Code:
    foo.c: In function ‘main’:
    foo.c:28:4: error: unknown type name ‘dint’; did you mean ‘int’?
       28 |    dint isPointerValid( void *ptr, ucap bytes )
          |    ^~~~
          |    int
    foo.c:28:36: error: unknown type name ‘ucap’
       28 |    dint isPointerValid( void *ptr, ucap bytes )
          |                                    ^~~~
    It was copy pasted from my own code, if people copying it can't work out how to replace a type that's clearly of integer origin then they shouldn't be programming yet

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,127
    Quote Originally Posted by awsdert View Post
    It was copy pasted from my own code, if people copying it can't work out how to replace a type that's clearly of integer origin then they shouldn't be programming yet
    You regularly post buggy code that you have not compiled and tested. Plus, what is 'ucap'?

    The majority of the users here are beginners, and it is NOT fair to force a beginner to debug your code before seeing if it answers their questions.

    Where is the documentation for both isPointerValid(), and stringcopy()? Please show me the man pages for both!

    Bottom line, this does not answer the users question. There is no standard way to inquire to the size of an allocation.

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    Quote Originally Posted by rstanley View Post
    You regularly post buggy code that you have not compiled and tested.
    IALWAYS compile and test it, it just that what worked for me didn't happen to work for another, that's just a normal thing in programming, if you can't get your head out of your ass and accept that then you should keep quite in these forums.

    Quote Originally Posted by rstanley View Post
    Plus, what is 'ucap'?
    That depends on the OS, on _WIN32 it's DWORD, anywhere else it's size_t, I'm trying to design my library to not use microsoft's buggy versions of the standard C library, musl is nice but since I'm supporting _WIN32 as best I can I might as well just skip standard c libs there and go straight for the OS calls, for now the code's not yet there but it will be eventually, I've even decoupled thread safety from the thread APIs, the only thing I needed to that end was a callback that just needs to be re-directed from the empty function it defaults to to one that makes the thread yield it's execution slice. No mutexes or semaphores need, just some pointers that should be NULL by default.

    Quote Originally Posted by rstanley View Post
    The majority of the users here are beginners, and it is NOT fair to force a beginner to debug your code before seeing if it answers their questions.
    In those case that's fair, but in this case the OP does not sound like a beginner, and I'm sure they're familiar with malloc & realloc, I really doubt they need telling how to convert the function to their own uses

    Quote Originally Posted by rstanley View Post
    Where is the documentation for both isPointerValid(), and stringcopy()? Please show me the man pages for both!
    If you can't tell what to expect from them & what to pass them despite seeing the code then you might need to relearn C, they are both cases where documentation is overkill, furthermore as I mentioned I haven't done a proper test for isPointerValid so documenting it would be stupid even if it did happen to work, experimental code & small example code should never be documented, it just adding useless fluff for the sake of a poll up one's own ass.

    Quote Originally Posted by rstanley View Post
    Bottom line, this does not answer the users question. There is no standard way to inquire to the size of an allocation.
    It does partially answer the users question to the extent of "you can confirm the amount of bytes that can be accessed without segfaulting", knowing if they can be accessed is an implicit requirement of any solution.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic C++ program doubt.
    By nitinmadan2015 in forum C++ Programming
    Replies: 3
    Last Post: 01-19-2016, 07:22 AM
  2. Basic doubt
    By pshirishreddy in forum C++ Programming
    Replies: 2
    Last Post: 09-15-2009, 11:00 AM
  3. basic doubt
    By vikranth in forum C Programming
    Replies: 7
    Last Post: 10-30-2007, 11:21 AM
  4. basic doubt
    By sincere_cute in forum C Programming
    Replies: 2
    Last Post: 06-20-2007, 03:33 AM
  5. [B]a basic doubt !![/B]
    By samirself in forum C Programming
    Replies: 6
    Last Post: 04-30-2005, 01:39 PM

Tags for this Thread