C प्रोग्रामिंग पैरामीटर

Nov 01 2020
#include <stdio.h>


void getScores(int a, char n[10][15], int s[10]) {
    int score;
    printf("Enter the number of students: ");
    scanf("%d",&a);
    for (int i=0; i < a;i++)
    {
            scanf("%s",n[i]);
            scanf("%d",&score);
            s[i]=score;
    }
}

void printScores(int a, char n[10][15], int s[10] ) {
    for (int i=0; i < a;i++)
    {
            printf("%s", n[a]);
            printf(" ");
            printf("%d\n",s[a]);
    }

}

int main() {
    char names[10][15];
    int scores[10];
    int num;


    getScores(num,names,scores);
    printScores(num,names,scores);
}

जो मैं पूरा करने की कोशिश कर रहा हूं, उसका उपयोग फ़ंक्शन int aसे पैरामीटर मान के रूप getScoresमें printScoresफ़ंक्शन में उपयोग की जाने वाली फ़ंक्शन लंबाई के रूप में किया जा रहा है getScores

जब प्रिंट फ़ंक्शन में उपयोग किया जाता है, तो सरणियां इसके मूल्य को बचा रही हैं, लेकिन aजब मैं फ़ंक्शन फ़ंक्शन में उपयोगकर्ता को प्रवेश करने की आवश्यकता होती है, तो यह मान किसी अनसाइनड नंबर 896 पर रीसेट हो जाता है। कोई सुझाव?

जवाब

P__JsupportswomeninPoland Nov 01 2020 at 14:51
  1. प्रिंट स्कोर कुछ भी प्रिंट नहीं करेगा।
void getScores(int *a, 

और पुकार

getScores(&num

आपको फ़ंक्शन कोड के अनुसार भी बदलने की आवश्यकता है