Adding an integer into a string

I have a program i am trying to write in unix c.

I have an ip address in a string variable


a.b.c


i want to make d and integer, and in a for loop vary its value from 0 - 255

so i can have a.b.c.(0-255)


how do i add the d part onto the variable ip_Addr


a.b.c.(int d)


any suggestions?


Comments

  • Try

    ip_Addr is the string

    value is the integer var.


    #include

    .

    .

    .

    sprintf(ip_Addr,"%s.%d",ip_Addr,value);


    I think this is the easier way.


    greetings

    SCIP


  • Try

    ip_Addr is the string

    value is the integer var.


    #include

    .

    .

    .

    sprintf(ip_Addr,"%s.%d",ip_Addr,value);


    I think this is the easier way.


    greetings

    SCIP


  • It's me again

    include the file string.h

    to use the sprintf operation.


    greetings

    SCIP


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories