R
Ryan Dupuis
I've been stuck on this. Now, bare in mind, I am still a beginner. I'm certain there are more efficient ways to code this, but I am writing this foran assignment and just need help resolving my strings from being promoted to integers.
argh!
script:
Script started on Mon 30 Sep 2013 11:18:46 PM EDT
redo.c: In function ‘main’:
redo.c:101:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:101:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:102:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:102:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:103:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:103:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:104:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:104:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:105:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:105:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:106:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:106:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:107:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:107:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:108:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:108:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:109:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:109:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:110:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:110:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:111:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:111:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
#include <stdio.h>
#include <math.h>
int main(void)
{
// initialize constants
const int tot_ctn = 2, tot_ctr_na = 3, tot_ctr_as = 8;
// initialize variables
// Contries
char ct1[256];
char ct2[256];
char ct3[256];
char ct4[256];
char ct5[256];
char ct6[256];
char ct7[256];
char ct8[256];
char ct9[256];
char ct10[256];
char ct11[256];
char contt1[256];
char contt2[256];
char contt3[256];
char contt4[256];
char contt5[256];
char contt6[256];
char contt7[256];
char contt8[256];
char contt9[256];
char contt10[256];
char contt11[256];
// Medals
int g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11;
int s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
int b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11;
// Totals
int tot_g, tot_s, tot_b;
int tot_m_all;
int tot_ctr;
int tot_m1, tot_m2, tot_m3, tot_m4, tot_m5, tot_m6, tot_m7, tot_m8, tot_m9,tot_m10, tot_m11;
// Averages
int avg_ctr, avg_contt;
// SCAN TIME!!!
printf("Use the following format to submit the data:\n");
printf("Country Continent GoldMedals SilverMedals Bronze Medals\n");
printf("\n");
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct1[256], &contt1[256], &g1, &s1, &b1);
printf("Awesome job! Now for country #2:\n");
scanf("%s %s %d %d %d", &ct2[256], &contt2[256], &g2, &s2, &b2);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct3[256], &contt3[256], &g3, &s3, &b3);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct4[256], &contt4[256], &g4, &s4, &b4);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct5[256], &contt5[256], &g5, &s5, &b5);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct6[256], &contt6[256], &g6, &s6, &b6);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct7[256], &contt7[256], &g7, &s7, &b7);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct8[256], &contt8[256], &g8, &s8, &b8);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct9[256], &contt9[256], &g9, &s9, &b9);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct10[256], &contt10[256], &g10, &s10, &b10);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct11[256], &contt11[256], &g11, &s11, &b11);
// SCAN COMPLETE
// Functions, baby!
tot_g = g1 + g2 + g3 + g4 + g5 + g6 + g7 + g8 + g9 + g10 + g11;
tot_s = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11;
tot_b = b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8 + b9 + b10 + b11;
tot_ctr = tot_ctr_na + tot_ctr_as;
tot_m1 = g1 + s1 + b1;
tot_m2 = g2 + s2 + b2;
tot_m3 = g3 + s3 + b3;
tot_m4 = g4 + s4 + b4;
tot_m5 = g5 + s5 + b5;
tot_m6 = g6 + s6 + b6;
tot_m7 = g7 + s7 + b7;
tot_m8 = g8 + s8 + b8;
tot_m9 = g9 + s9 + b9;
tot_m10 = g10 + s10 + b10;
tot_m11 = g11 + s11 + b11;
tot_m_all = tot_g + tot_s + tot_b;
// Averages
avg_ctr = tot_m_all / tot_ctr;
avg_contt = tot_m_all / tot_ctn;
//Printing Time!
printf("COUNTRY\t CONTINENT\t #GOLD\t #SILVER\t #BRONZE\t #TOTAL\n");
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct1[256], contt1[256], g1, s1, b1, tot_m1);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct2[256], contt2[256], g2, s2, b2, tot_m2);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct3[256], contt3[256], g3, s3, b3, tot_m3);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct4[256], contt4[256], g4, s4, b4, tot_m4);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct5[256], contt5[256], g5, s5, b5, tot_m5);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct6[256], contt6[256], g6, s6, b6, tot_m6);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct7[256], contt7[256], g7, s7, b7, tot_m7);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct8[256], contt8[256], g8, s8, b8, tot_m8);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct9[256], contt9[256], g9, s9, b9, tot_m9);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct10[256], contt10[256], g10, s10, b10, tot_m10);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct11[256], contt11[256], g11, s11, b11, tot_m11);
printf("Totals\t 11\t %d\t %d\t %d\t %d\n", tot_g, tot_s, tot_b, tot_m_all);
printf("/n");
printf("The average medals per: Country = %d\t Continent = %d", avg_ctr, avg_contt);
// END
return 0;
}
argh!
script:
Script started on Mon 30 Sep 2013 11:18:46 PM EDT
redo.c: In function ‘main’:
redo.c:101:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:101:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:102:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:102:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:103:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:103:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:104:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:104:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:105:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:105:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:106:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:106:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:107:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:107:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:108:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:108:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:109:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:109:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:110:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:110:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
redo.c:111:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
redo.c:111:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
#include <stdio.h>
#include <math.h>
int main(void)
{
// initialize constants
const int tot_ctn = 2, tot_ctr_na = 3, tot_ctr_as = 8;
// initialize variables
// Contries
char ct1[256];
char ct2[256];
char ct3[256];
char ct4[256];
char ct5[256];
char ct6[256];
char ct7[256];
char ct8[256];
char ct9[256];
char ct10[256];
char ct11[256];
char contt1[256];
char contt2[256];
char contt3[256];
char contt4[256];
char contt5[256];
char contt6[256];
char contt7[256];
char contt8[256];
char contt9[256];
char contt10[256];
char contt11[256];
// Medals
int g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11;
int s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
int b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11;
// Totals
int tot_g, tot_s, tot_b;
int tot_m_all;
int tot_ctr;
int tot_m1, tot_m2, tot_m3, tot_m4, tot_m5, tot_m6, tot_m7, tot_m8, tot_m9,tot_m10, tot_m11;
// Averages
int avg_ctr, avg_contt;
// SCAN TIME!!!
printf("Use the following format to submit the data:\n");
printf("Country Continent GoldMedals SilverMedals Bronze Medals\n");
printf("\n");
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct1[256], &contt1[256], &g1, &s1, &b1);
printf("Awesome job! Now for country #2:\n");
scanf("%s %s %d %d %d", &ct2[256], &contt2[256], &g2, &s2, &b2);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct3[256], &contt3[256], &g3, &s3, &b3);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct4[256], &contt4[256], &g4, &s4, &b4);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct5[256], &contt5[256], &g5, &s5, &b5);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct6[256], &contt6[256], &g6, &s6, &b6);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct7[256], &contt7[256], &g7, &s7, &b7);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct8[256], &contt8[256], &g8, &s8, &b8);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct9[256], &contt9[256], &g9, &s9, &b9);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct10[256], &contt10[256], &g10, &s10, &b10);
printf("Let's start with country #1:\n");
scanf("%s %s %d %d %d", &ct11[256], &contt11[256], &g11, &s11, &b11);
// SCAN COMPLETE
// Functions, baby!
tot_g = g1 + g2 + g3 + g4 + g5 + g6 + g7 + g8 + g9 + g10 + g11;
tot_s = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11;
tot_b = b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8 + b9 + b10 + b11;
tot_ctr = tot_ctr_na + tot_ctr_as;
tot_m1 = g1 + s1 + b1;
tot_m2 = g2 + s2 + b2;
tot_m3 = g3 + s3 + b3;
tot_m4 = g4 + s4 + b4;
tot_m5 = g5 + s5 + b5;
tot_m6 = g6 + s6 + b6;
tot_m7 = g7 + s7 + b7;
tot_m8 = g8 + s8 + b8;
tot_m9 = g9 + s9 + b9;
tot_m10 = g10 + s10 + b10;
tot_m11 = g11 + s11 + b11;
tot_m_all = tot_g + tot_s + tot_b;
// Averages
avg_ctr = tot_m_all / tot_ctr;
avg_contt = tot_m_all / tot_ctn;
//Printing Time!
printf("COUNTRY\t CONTINENT\t #GOLD\t #SILVER\t #BRONZE\t #TOTAL\n");
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct1[256], contt1[256], g1, s1, b1, tot_m1);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct2[256], contt2[256], g2, s2, b2, tot_m2);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct3[256], contt3[256], g3, s3, b3, tot_m3);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct4[256], contt4[256], g4, s4, b4, tot_m4);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct5[256], contt5[256], g5, s5, b5, tot_m5);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct6[256], contt6[256], g6, s6, b6, tot_m6);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct7[256], contt7[256], g7, s7, b7, tot_m7);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct8[256], contt8[256], g8, s8, b8, tot_m8);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct9[256], contt9[256], g9, s9, b9, tot_m9);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct10[256], contt10[256], g10, s10, b10, tot_m10);
printf("%s\t %s\t %d\t %d\t %d\t %d\t\n", ct11[256], contt11[256], g11, s11, b11, tot_m11);
printf("Totals\t 11\t %d\t %d\t %d\t %d\n", tot_g, tot_s, tot_b, tot_m_all);
printf("/n");
printf("The average medals per: Country = %d\t Continent = %d", avg_ctr, avg_contt);
// END
return 0;
}