I m a learner in C . while doing the following code Error Msg is array subscript is not an Integer. why that eroor came?
#include<stdio.h>
void main()
{
char char_s[25],array_s[5];
int int_m,array_m[5];
printf("Enter Student name and Mark");
scanf("%s %d",array_s[char_s],&array_m[int_m]);
Copyright © 2024 QUIZLS.COM - All rights reserved.
Answers & Comments
Verified answer
scanf("%s %d",array_s[char_s],&array_m[int_m]);
-->
array_s[char_s] --> you are trying to index the array array_s, but you pass it char_s which is an array of chars, NOT an integer.
If you want a string from the input, you should just pass a char array, either char_s or array_s:
scanf("%s %d",array_s,&array_m[int_m]);
This will fill the char array array_s with the characters from the input.
you may no longer use a non-imperative datatype as a subscript; you need to use the int datatype. For e9dd4e461268c8034f5c8564e155c67a6ample: // calculate sum for (int x = 0; x < 4; x = x + a million) entire = entire + fee[x]; //end for