Continue to Site

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.

  • 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

  • RFID.c
    7.3 KB · Views: 216
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
 
Try
Code:
if (!strcmp((char*)Kodas[k], (char*)kort_duom)
and see if the compiler accepts that
 
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:
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?
 
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.
 
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.
 
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

New Articles From Microcontroller Tips

Back
Top