Συντονιστής: konnn



19:1: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘int’#include <stdio.h>
main()
{
int kilos;
int money;
int money_to_pay;
char currency;
printf("What is the currency?\n");
scanf("%s",¤cy);
fflush(stdin);
printf("How many kilos is your product?");
scanf("%d",&kilos);
fflush(stdin);
printf("How much does a kilo cost?");
scanf("%d",&money);
fflush(stdin);
money_to_pay = kilos * money;
printf("You will pay %d %s",money_to_pay,currency);
}


clepto έγραψε:όχι...θα φτιάξω μερικά πράγματα και θα ποστάρω τον κώδικα σε καινούργιο νήμα
@stamatiou
αντικατέστησε το %s με %c


int main( void )
int main( int argc, char *argv[] )
stamatiou έγραψε:#include <stdio.h>
main()
{
int kilos;
int money;
int money_to_pay;
char currency;
printf("What is the currency?\n");
scanf("%s",¤cy);
fflush(stdin);
printf("How many kilos is your product?");
scanf("%d",&kilos);
fflush(stdin);
printf("How much does a kilo cost?");
scanf("%d",&money);
fflush(stdin);
money_to_pay = kilos * money;
printf("You will pay %d %s",money_to_pay,currency);
}

#include <stdio.h>
int main(void)
{
int i;
int input;
int sum = 1;
for(i = 0;i<10;i++)
{
printf("Insert the %d number:\n",i+1);
scanf("%d",&input);
if(input % sum == 0)
{
sum = sum + input;
}
}
printf("The sum of the numbers that are divided by 3 without leaving a remainder is %d\n",sum);
exit(0)
}
Floating point exception
stamatiou έγραψε:Ναι αλλά το error λέει ότι είναι int και όχι char, και αν θέλω να δηλώσω string πρέπει ένα array για chars;
char currency[100]="";
έγραψε:
Αυτό είναι εκτός:
Έχω τον παρακάτω κώδικα:
- Κώδικας: Επιλογή όλων
[snip]
Και μου βγάζει error:
- Κώδικας: Επιλογή όλων
Floating point exception
Αλλά αφού έχω κάνει compile και τρέξει το πρόγραμμα.
