I wonder, does it make a difference where I declare local variables in a function? So for example this:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
{
uid_t uid; //Declare it right here?
if (argc < 2)
{
showUsage(argv[0]);
return 0;
}
//Or should I declare uid_t variable here
uid = getuid();
if (uid > 0)
{
printf("\nroot privileges required!\n");
return 0;
}
return 0;
}
I declare a uid_t variable above the first IF statement where I check if there're arguments to use. Does it make a difference when I declare the uid_t variable beneath the first IF statement? So, would it be 'more efficient' if I declare variables at that place when I'm sure that they are going to be used or does it make no difference?