Thread: subnet string to slash notation?

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    subnet string to slash notation?

    Are there any standard posix c functions to convert a subnet string in dot notation to its slash notation int value? For example something like:

    inet_atoi("255.255.255.0") returning 24

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Why don't you just include sockets or winsock and use the functions it gives?

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    127
    Oh, a lot of reason. But mostly time. I don't want to spend days reading through text just to see if such a function exists. I ended up writing my own, but am still curious to know if such a function exists, and if it does, what is it called?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by homer_3 View Post
    Oh, a lot of reason. But mostly time. I don't want to spend days reading through text just to see if such a function exists. I ended up writing my own, but am still curious to know if such a function exists, and if it does, what is it called?
    It's really not that tedious...

    Winsock Functions (Windows)

    There ya go, all on one page.

  5. #5
    Registered User
    Join Date
    Nov 2008
    Posts
    127
    1) From that, it looks lilke the answer is no. That function doesn't exist. So why ask me to look for something that isn't there.

    2) winsock = posix now?

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by homer_3 View Post
    1) From that, it looks lilke the answer is no. That function doesn't exist. So why ask me to look for something that isn't there.
    Woah! Take it easy with that attitude. Expecting anybody to hold the full contents of the sockets API in their head and just spit out what you want is just plain silly. You even copped to being too lazy to look it up ("I don't want to spend days...wah wah wah"). I'm sure you didn't expect Tater to actually read through the sockets API docs for you and give you an answer. He merely gave you a comprehensive list of sockets functions for you to check, doing the Google search you should have done in the first place. Besides, I'm sure the "days" you spent looking at the documentation (which was really only 50 minutes) didn't hurt you any. Now you know the answer to your question, and probably learned something else along the way.

    2) winsock = posix now?
    No, but they are extremely similar, since both were based on Berkeley's BSD sockets implementation. Most code is interchangeable, and that was probably the first doc that Tater could get a hold of. Again, try being a little more polite to those who are trying to help you, and realize that just because he didn't link you to a page with a giant flashing sign saying "Look homer_3! The exact function you want is right here!", doesn't mean that you couldn't have found functions to help you roll your own by putting in a little effort.

  7. #7
    Registered User
    Join Date
    Nov 2008
    Posts
    127
    Quote Originally Posted by anduril462 View Post
    He merely gave you a comprehensive list of sockets functions for you to check, doing the Google search you should have done in the first place.
    Do you really think I didn't do a google search before asking? I didn't find anything, so I posted here on the chance that someone might know. Perhaps someone else that visits these forums had a similar problem. If they don't know, fine. But I don't expect "why don't you read the entire C socket API LOL!"

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by homer_3 View Post
    Do you really think I didn't do a google search before asking? I didn't find anything, so I posted here on the chance that someone might know. Perhaps someone else that visits these forums had a similar problem. If they don't know, fine. But I don't expect "why don't you read the entire C socket API LOL!"
    But you expect me to read it for you?

    Do you have even the first clue how many man-hours a simple question here invokes?

  9. #9
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by homer_3 View Post
    Do you really think I didn't do a google search before asking? I didn't find anything, so I posted here on the chance that someone might know. Perhaps someone else that visits these forums had a similar problem. If they don't know, fine. But I don't expect "why don't you read the entire C socket API LOL!"
    There was no indication that you tried a Google search in any of your posts (until now, but it's too late), and in your the second post, you basically said "I'm too lazy to read docs". That doesn't go over well with anybody here. Actually, it's a pretty good way to not get helped. This is how the conversation reads:

    you: Is there a function for x?
    Tater: Try checking the following APIs...
    you: I'm lazy, can't you find the answer for me.
    Tater: Here's a link to a list of all the functions in said API. See if what you need is on that list.
    you: !%$@$ Wah, wah, wah! Why are you so mean!?!

    And nobody ever told you to read the whole API, just a brief summary of the available functions. Basically, you could have eliminated 90% of those functions by reading the name and/or brief descriptions, which should have taken all of a minute or two. Then, maybe you had to read a little more into 4 or 5 of them to see if they perhaps did what you want. Total time required? 15 minutes max. BFD. We're not here to RTFM on your behalf. If you don't tell us you did your research and read the docs and still can't find it, we assume you're lazy. You'd be surprised at just how many people come to us with "can you write a program for me" questions...naturally, we're a bit jaded.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM