?
Solved

I get this compiler error message

Posted on 2003-12-02
8
Medium Priority
?
478 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
7 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

807 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