In C, I would like to limit the string to the first 8 characters. For example, I have:
char out = printf("%c", str);
How can I make it so it only returns the first 8 characters?
For example,
#include <stdio.h>
int main (int argc, const char * argv[]) {
char out = printf("teststring");
printf("%d\n", out);
return 0;
}
will return teststring10. Anyone has an idea how to get rid of the 10?
Thanks in advance.
I've spent the last few hours trying to port this to C, with no success. Can someone please help?
function zerofill($a, $b) {
$z = hexdec(80000000);
if ($z & $a) {
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
} else {
$a = ($a>>$b);
}
return $a;
}
I am trying to encode a string in hex8 using c. The script I have right now is:
int hex8 (char str) {
str = printf("%x", str);
if(strlen(str) == 1) {
return printf("%s", "0", str);
} else {
return str;
}
}
In this function, I will need to add a 0 ahead of the string if the length is less than 1. I don't know why I'm getting:
passing argument 1 of 'strlen' makes pointer from integer without a cast
Does anyone know why?