Thank you both. I'm using Windows 10, and justr followed BlueHazzard's & stahta01's advice. The compiler was detected and the program now attempts to compile. However, it did not compile and here is the error message:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
||error: C:\Users\jfele\OneDrive\??\2.Learning\f. My own studies\Computing\C\25.c: Invalid argument|
||error: no input files|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
I just walked through my code and did not find any errors. Is it because it cannot include the two #include .h files?
Is this another easy fix?
Appreciate any help. Here is my short program:
// Example program #1 from Chapter 15 of Absolute Beginner's Guide
// to C, 3rd Edition
// File Chapter15ex1.c
/* This program will ask users how many movies they've seen this
year, and then loop through asking the name of each movie and a
rating from 1 to 10. It will remember their favourite movie and
their least favourite movie. */
#include <stdio.h>
#include <string.h>
main()
{
int ctr, numMovies, rating, favRating, leastRating;
char movieName[40], favorite[40], least[40];
// Initialize the favRating to 0 so any movie with any rating of
// 1 or higher will replace it and the leastRating to 10 so any
// movie rated 9 or lower will replace it
favRating = 0;
leastRating = 10;
// Find out how many movies the user has seen and can rate
// The loop will continue until they enter a number more than 0
do {
printf("How many movies have you seen this year?");
scanf(" %d", &numMovies);
// If the user enters 0 or a negative number, the program
// will remind them to enter a positive number and prompt
// them again
if (numMovies < 1)
{
printf("No movies! How can you rank them?\nTry again!\n\n");
}
} while (numMovies < 1);
for (ctr = 1; ctr <= numMovies; ctr++)
{
// Get the name of the movie and the user's rating
printf("\nWhat was the name of the movie? ");
printf("(1-word titles only!) ");
scanf(" %s", movieName);
printf("On a scale of 1 to 10, what would ");
printf("you rate it? ");
scanf(" %d", &rating);
// Check whether it's their best-rated movie so far
if (rating > favRating)
{
strcpy(favorite, movieName);
favRating = rating;
}
// Check whether it's their worst-rated movie so far
if (rating < leastRating)
{
strcpy(least, movieName);
leastRating = rating;
}
}
printf("\nYour favourite movie was %s.\n", favorite);
printf("\nYour least favourite movie was %s.\n", least);
return 0;
}