Solved

I get this compiler error message

Posted on 2003-12-02
8
462 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
Comment Utility
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
Comment Utility
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
Comment Utility
The problem is that I can not use a pointer to determine the string length.  
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:Sys_Prog
Comment Utility
Hi buckeyes33,

What's the declaration for pbin1

Amit
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 250 total points
Comment Utility
>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
Comment Utility
Sys_prog
I figured it out and ask CS to delete question they just have not yet.
0
 
LVL 9

Author Comment

by:buckeyes33
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 and use structures in the C programming language.

744 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

10 Experts available now in Live!

Get 1:1 Help Now