I didnt understood why this message apeared in my terminal:
Please enter your 1st variable that you want to calculate the percentage of without any spaces: morangos PS C:\Users\TechnoStoreReparacoe\Desktop>
this is the full code:
#include <stdio.h>
#include <string.h>
int main (){
char name1[25] ;
char name2[25] ;
char name3[25];
char name4[25];
char name5[25];
int value1 ;
int value2 ;
int value3 ;
int value4 ;
int value5 ;
printf ("Hello mortal, this program allows you to calculate percentages of five parts that are the only components of the whole.\n");
printf ("\nPlease enter your 1st variable that you want to calculate the percentage of without any spaces:\n");
fgets (name1, 25, stdin);
printf ("\nPlease enter the value of %s:\n", name1[25]);
scanf ("%i", &value1);
printf ("\nPlease enter your 2nd variable that you want to calculate the percentage of without any spaces:\n");
fgets (name2, 25, stdin);
printf ("\nPlease enter the value of %s:\n", name2[25]);
scanf ("%i", &value1);
printf ("\nPlease enter your 3rd variable that you want to calculate the percentage of without any spaces:\n");
fgets (name3, 25, stdin);
printf ("\nPlease enter the value of %s:\n", name3[25]);
scanf ("%i", &value1);
printf ("\nPlease enter your 4th variable that you want to calculate the percentage of without any spaces:\n");
fgets (name4, 25, stdin);
printf ("\nPlease enter the value of %s:\n", name4[25]);
scanf ("%i", &value1);
printf ("\nPlease enter your 5th variable that you want to calculate the percentage of without any spaces:\n");
fgets (name5, 25, stdin);
printf ("\nPlease enter the value of %s:\n", name5[25]);
scanf ("%i", &value1);
return 0;
}
Im making a probability finder program, very simple. where the user inputs variables names and respective numerical values. Its my first program, and I dont understood why the code isnt running well
printf()expects achar *, not acharname1[25]in theprintf()is the 25th (staring from 0) element of arrayname1[]. Thatcharis outside the arrayname[]and cannot be read."%s"expects a matching pointer, achar *.