On the code that involves replacing %c with %s (at the beginning):
Interesting. I thought you would have removed the ampersand from var_name, because you are passing in an array, right?
But on to your actual problem. Just as a note, when something doesn't work, don't guess the code. You'll typically make things worse (as you did here).
First, I'll note the problems in your two code snippets involving character comparisons. In the first snippet, the issue is using "z" instead of 'z'. Yes, the quote type matters. "z" creates a C string. 'z' creates a character.
The error message is a bit cryptic if you are a beginner in C. So, var_name is a char. That's simple. Now look at "z". First, it's a constant. It's a constant as much as if you had typed the number 5 in place of it. Second, a C string can be pointed to with a char*. You have a constant string literal, so you have a const char*. And you try to compare that to a char. Hence the compilation error. You actually wanted the char 'z'. So use the single quotes.
---
But your second snippet is even worse. So you added a * to var_name, and now you have a character pointer. This gives you an immediate problem. Suddenly, you no longer have a character. So what you have to do is allocate memory for a character, and then point var_name to it. I'm betting you omitted this portion in your code.
Of course, the var_name != "z" comparison will pass. You are comparing two char pointers. It's always going to return false though. "z" occupies a certain place in memory. var_name isn't going to point to it. That is what comparing two pointers does, by the way. It compares if the pointer values are equal. So when you have
-
char *cstr1, *cstr2;
-
... cstr1 == cstr2 ...
-
That comparison doesn't check if the string contents match. You need to explicitly go through the string contents and check if each individual character matches up with one another. That's why there is a function in the library strcmp and strncmp to do so for you.
But you never wanted a string comparison anyway. Change "z" to 'z' and you're set to go.