Passing arg 1 of `atoi' makes pointer from integer without a cast, Please help.

This is a discussion on Passing arg 1 of `atoi' makes pointer from integer without a cast, Please help. within the C Programming forums, part of the General Programming Boards category; Code: char c,tmp[3],camadas_dados[5000],*ptr; int camada_actual,area_camada,boxes_camada,wires_camada,temp,layers,boxes,wires,bk; void dadosCamada () { int s; //0 = area_camada, 1 = boxes_camada, 2 = wires_camada ...

  1. #1
    Banned
    Join Date
    Mar 2008
    Posts
    78

    Passing arg 1 of `atoi' makes pointer from integer without a cast, Please help.

    Code:
    char c,tmp[3],camadas_dados[5000],*ptr;
    int camada_actual,area_camada,boxes_camada,wires_camada,temp,layers,boxes,wires,bk;
    
        void dadosCamada () {
             int s; //0 = area_camada, 1 = boxes_camada, 2 = wires_camada
             bk=pX;
             area_camada = boxes_camada = wires_camada = 0;
             
             while(camadas_dados[bk] != ']') {
              if(isdigit(camadas_dados[bk])) {
               area_camada = (s == 0) ? area_camada*10 + atoi(camadas_dados[bk]) : area_camada;
               boxes_camada = (s == 1) ? boxes_camada*10 + atoi(camadas_dados[bk]) : boxes_camada;
               wires_camada = (s == 2) ? wires_camada*10 + atoi(camadas_dados[bk]) : wires_camada;
              }
              else if(s!=0){s++;}
              bk++;
             }
             }

    I'm getting the error here:

    PHP Code:
               area_camada = (== 0) ? area_camada*10 atoi(camadas_dados[bk]) : area_camada;
               
    boxes_camada = (== 1) ? boxes_camada*10 atoi(camadas_dados[bk]) : boxes_camada;
               
    wires_camada = (== 2) ? wires_camada*10 atoi(camadas_dados[bk]) : wires_camada
    [Warning] passing arg 1 of `atoi' makes pointer from integer without a cast
    [Warning] passing arg 1 of `atoi' makes pointer from integer without a cast
    [Warning] passing arg 1 of `atoi' makes pointer from integer without a cast
    This error may be very stupid but i can't find it.. Thanks for helping

  2. #2
    Banned
    Join Date
    Mar 2008
    Posts
    78
    I edited the post to add the line:
    char c,tmp[3],camadas_dados[5000],*ptr;

  3. #3
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    atoi() as the name suggests, takes an array and returns and integer. You're giving it a char.
    try
    Code:
    atoi(camadas_dados)
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  4. #4
    Banned
    Join Date
    Mar 2008
    Posts
    78
    Quote Originally Posted by NeonBlack View Post
    atoi() as the name suggests, takes an array and returns and integer. You're giving it a char.
    try
    Code:
    atoi(camadas_dados)
    Omg you're right! Stupid me.

    can i make atoi(camadas_dados+bk) ? because camadas_dados will start from [0], i want it to start from [bk].

    Thanks!

  5. #5
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    It should work.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  6. #6
    Banned
    Join Date
    Mar 2008
    Posts
    78
    Okay, thank you

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    This works:
    Code:
    atoi(camadas_dados+bk)
    But another way of doing it, if you're interested, is:
    Code:
    atoi(&camadas_dados[bk])
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. warning: cast to pointer from integer of different size
    By DavidDobson in forum C Programming
    Replies: 6
    Last Post: 12-03-2008, 05:37 PM
  2. Replies: 1
    Last Post: 03-24-2008, 10:16 AM
  3. "assignment makes integer from pointer without a cast"
    By Freez3L in forum C Programming
    Replies: 4
    Last Post: 11-04-2002, 03:26 AM
  4. assignment makes pointer from integer
    By crescen7 in forum C Programming
    Replies: 4
    Last Post: 06-25-2002, 10:08 PM
  5. Replies: 3
    Last Post: 01-14-2002, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21