Solved

I get this compiler error message

Posted on 2003-12-02
8
471 Views
Last Modified: 2011-10-03
what does this mean:

warning: passing arg 1 of `strlen' makes pointer from integer without a cast
0
Comment
Question by:buckeyes33
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:Gratch06
ID: 9863235
you're probably calling a function such as:

function1(int* intVar);

with the function call:

function1(strlen(....));

In which case, the strlen funtion returns an integer, but your funtion wants a pointer to a value (integer or otherwise).  C will not dereference and convert this to a pointer, but will take the value as is and use it as a pointer, a flaw which can prove fatal to your program.
0
 
LVL 9

Author Comment

by:buckeyes33
ID: 9863289
the lines the the compiler are telling me tis the problem are for for loops

here is an example

 for(i = 0; i <= strlen(*pbin1)- 1; i ++)
    {
      if(*pbin1[i] != BINNUM1 && *pbin1[i] != BINNUM0)
      {
        j = 1;
      }
    }
0
 
LVL 9

Author Comment

by:buckeyes33
ID: 9863677
The problem is that I can not use a pointer to determine the string length.  
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:Sys_Prog
ID: 9864305
Hi buckeyes33,

What's the declaration for pbin1

Amit
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 250 total points
ID: 9864343
>warning: passing arg 1 of `strlen' makes pointer from integer without a cast
means that the first argument being passed to strlen is supposed to be a char * but you are passing an int instead and that too without explicitly casting it

for(i = 0; i <= strlen(*pbin1)- 1; i ++)
pbin1 could be a char * or an int * but *pbin1 means the value at that address which will be a char or an int ... You need to pass the starting "address" of the string
0
 
LVL 9

Author Comment

by:buckeyes33
ID: 9864345
Sys_prog
I figured it out and ask CS to delete question they just have not yet.
0
 
LVL 9

Author Comment

by:buckeyes33
ID: 9871413
I just decided that since Sunnycoder got the correct answer that I will accept his question.  I did not state how I figured it out where as he did.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
logging Access violation 6 24
Need example 5 137
Synchronization using condition variables to avoid locking in C 8 104
Test the speeds on my PC Drives 12 79
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question