In my if statement I am trying to say, "if there is a space in strlen subtract that space then print strlen." My goal is to count only the letters that appear in the string and not the spaces. If there is something I can do to fix a nudge in the right direction would be appreciated. Im currently down to one error.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
int main (void)
{
int x = ' ';
// prompt user for text
string t = get_string("Enter Text:\n");
if(strlen(t) == x)
{
strlen(t) - x;
}
else printf("letters: %lu\n" , strlen(t));
// for every letter count 1 and print total
}
Disclaimer: before I had x as an integer I was using ' ' in it's place to represent a space(' '). I thought maybe if I gave space(' ') a value such as x. the program would be able to understand x is a space. take x out. this didn't work for me though.
error message reads: clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow readability.c -lcrypt -lcs50 -lm -o readability
readability.c:13:18: error: expression result unused [-Werror,-Wunused-value]
strlen(t) - x;
~~~~~~~~~ ^ ~