ist dies nicht eine verschachtelte Funktion in C ? (die Funktion displayAccounts())
Ich weiß, ich hätte die Funktion anders definiert und Variablen übergeben und was nicht, aber irgendwie funktioniert gut, da ich die Konten mehrmals drucken musste.
(snipet von einer Schulaufgabe gemacht) ...
//function 'main' that executes the program.
int main(void)
{
int customerArray[3][3] = {{1, 1000, 600}, {2, 5000, 2500}, {3, 10000, 2000}}; //multidimensional customer data array.
int x, y; //counters for the multidimensional customer array.
char inquiry; //variable used to store input from user ('y' or 'n' response on whether or not a recession is present).
//function 'displayAccounts' displays the current status of accounts when called.
void displayAccounts(void)
{
puts("\t\tBank Of Despair\n\nCustomer List:\n--------------");
puts("Account # Credit Limit\t Balance\n--------- ------------\t -------");
for(x = 0; x <= 2; x++)
{
for(y = 0; y <= 2; y++)
printf("%9d\t", customerArray[x][y]);
puts("\n");
}
}
displayAccounts(); //prints accounts to console.
printf("Is there currently a recession (y or n)? ");
//...
return 0;
}
scheint ein Duplikat zu sein: http://stackoverflow.com/questions/1348095/why-are-nested-functions-not-supported-by- the-c-standard – zoli2k
auch http://stackoverflow.com/questions/666586/are-nested-functions-part-of-c-standard und http://stackoverflow.com/questions/2256647/is-it-possible -in-c-or-c-zu-erstellen-eine-Funktion-innerhalb-andere und http://stackoverflow.com/questions/957592/functions-inside-functions-in-c und andere von http: // stackoverflow.com/search?q=nested+functions+[c] – dmckee
Verwenden Sie Python, es ist einfacher. –