so im getting
scrabble.c:20:32: error: incompatible pointer types passing
'string' (aka 'char *') to parameter of type 'int *'
[-Werror,-Wincompatible-pointer-types]
because of this line specifically
int score1 = compute_score(word1);
word one that player one types in has numbers assigned to it. "compute_score" is a custom function and the input to that is the global variable POINTS[]. heres the code:
#include <ctype.h>
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// points assigned to each letter of the alphabet
int POINTS[]= {1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10};
int compute_score(int POINTS[]);
int main(int argc, string argv[])
{
//get input from both players
string word1 = get_string("player 1: ");
string word2= get_string("player 2: ");
//score both words
int score1 = compute_score(word1);
int score2 = compute_score(word2);
//print the winner
if ( score1 > score2)
{
printf("player 1 wins!!!");
}
else if ( score2 > score1)
{
printf("player 2 wins!!!");
}
else if (score1 == score2)
{
printf("TIE!");
}
}
// declare function to compute score
int compute_score(int POINTS[])
{
// convert non capitol letters to capitol
int score1 = ((int POINTS[]), toupper);
return score1;
int score2 = ((int POINTS[]), toupper);
return score2;
}
ive flirted with the idea of using a function in the library that i think is supposed to force this conversion but i cant remember what its called, or did i just flat out do this wrong?
heres my for loop (pretty sure is erroneous)
string word1;
for (int i=0, n= strlen(word1); i <n; i++)
{
int score1 = POINTS, toupper;
return score1;
}