• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

illegal pointer conversion

Status
Not open for further replies.

justas12

New Member
hi, i have a program source code, but i added some function. and now there are three the same errors, "illegal pointer conversion" how to correct them? compiler mikroc
 

Attachments

Smartie

Member
Can post the error log from the compiler as I don't have Mikro C installed any more and don't want to reinstall it
 

Smartie

Member
Try
Code:
if (!strcmp((char*)Kodas[k], (char*)kort_duom)
and see if the compiler accepts that
 

smanches

New Member
if (!strcmp(&Kodas[k], kort_duom))

It's looking for pointers and you're giving it a single char. You must give it the address of that char instead.

& == address of
 
Last edited:

CCD

New Member
if (!strcmp(&Kodas[k], kort_duom))
I think this will compare the string Kodas starting with position k & string kort_duom starting with it's first character to the same number of characters Kodas[k] has (from position k to end of Kodas)
For example, if Kodas="abcdefgh" & kort_duom="qwertyuiop", and if k=2, then strcmp(&Kodas[k], kort_duom) will compare "cdefgh" with "qwerty".
Is it that you want?
 

Pommie

Well-Known Member
Most Helpful Member
My only concern is that Kodas will produce a ROM pointer and kort_duam a RAM pointer. I don't know MikroC well enought to be sure but I think strcmp expects 2 RAM pointers.

Mike.
 

justas12

New Member
so i correct that error. The other problem is how to compare Kodas[] with code wich i receive from reader. if they match i sould get ok message in lcd, othewise error. compilator doesnt find any errors, but i doesnt work.
 

Hayato

Member
1 st problem: You are trying to compare a whole string with an int, using a strcomp. It won't work.
2 nd problem: Kodas has 4 strings with N size. So you have to use 2 different indexes, ok? Not Kodas[k][k] but Kodas[k][j], for example.

Wrong -> if (!strcmp(Kodas[k][k], kort_duom))

Try this one: if (atoi(Kodas[k][k])== kort_duom)

Don't forget the
#include <stdio.h>
#include <stdlib.h>
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top