Solved

I get this compiler error message

Posted on 2003-12-02
8
464 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
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

Question has a verified solution.

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

Suggested Solutions

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 recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now