Does anyone know how to program in C? Because if they do I would like with identifying this issue called a semantic issue in Xcode 4.6.3. Here is the text that is says after the issue: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' I will attach the code in the 1st sub post.
#include <stdio.h> #include <string.h> int main(){ printf("My name is Burney Hy"); printf("My address is 4750 Nexus Center Drive, San Diego, California, 92121"); printf("My phone number is 858-848-1057"); char name[]= "The Beatles"; int length; length =strlen(name); printf("There are %d characters in the string.", length); return 0; }
length =strlen(name); This is the line of code where it shows the error. If anyone can help, it is appreciated. Will give out a medal for help that is given.
Does strlen() return an int or an unsigned int?
The man page does nit say what it returns other than a number: http://www.manpagez.com/man/3/strlen/ Might want to static cast it to an int, or find the type it returns with a small test bit of code to find out what it returns so you can make sure to declare the same type of variable. That has a good chance of dealing with
This is what the semantic issue says: Here is the text that is says after the issue: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' @e.mccormick
Ah, so it is a type mismatch. You either need to deal with it as an unsigned long, or static cast it to the right type.
Join our real-time social learning platform and learn together with your friends!