Hello everyone, I'm very new to C and programming in general. Apologies if this is a very obvious mistake but I'm stuck and not sure what to do. I'm trying to do a set function on one of my variables and when I pass my int pointer and change the value in the function. The int in my main program always turns out to be 1 for whatever reason.
Code:
#include <stdio.h>
#include <stdlib.h>
#include"employee.h"
void setNumberOfEmployees(int* numEmployees);
int main()
{
int employees; // amount of employees that signed up for LWOP
int* pEmployees = &employees;
setNumberOfEmployees(pEmployees);
printf("%d", employees);
struct employee lwopListed[employees];
return 0;
}
void setNumberOfEmployees(int* numEmployees) {
int employees = scanf("%d", &employees);
if (employees > 0)
*numEmployees = employees;
return;
}
/* output
23 // this is the number I entered in the setEmployeeNumber function
1 // and this is the value of employees after the function
Process returned 0 (0x0) execution time : 3.260 s
Press any key to continue.
*/