There is a string IP address. How to convert it to byte array?
Closed due to the fact that the essence of the issue is not clear to the participants Vlad from Moscow , Vladimir Martyanov , vp_arth , user194374, Harry 22 Feb '17 at 12:36 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
|
1 answer
Most likely, you work with sockets. Then pay attention to such functions as, for example, inet_aton and others, described, for example, here .
If you are interested in a purely abstract question, then you can write something like
int a[4]; sscanf(addr,"%d.%d.%d.%d",&a[0],&a[1],&a[2],&a[3]); and check that 4 values were read, and all of them fit in the range of 0-255 ...
- Tags arduino. There is no clean c - Radzhab
- Then remove the "C" tag :) - Harry
- You are both confusing C with the standard C library . - 0andriy
|
inet_aton()? - Mike