I have a function that gets an integer as a parameter. I want to send a char array's address to it, then print the array from its address. I mean:
void printSomeThing(int x){
printf("Variable is: %s\n", /*What to type here?*/);
//I want this printf to write "file.txt"
}
....
int main(){
char filename[10] = "file.txt";
char *filePointer = filename; //So it points to filename[0]'s address.
int x = /*How to convert the address of the pointer (or the char array) to an integer?*/
printSomeThing(x);
}
So, I want to send the char array's address to the function and print that address's value.
NOTE: I can't change the printSomeThing
parameter. It has to be an int
.