Suppose you have declared a struct called Movie. A Movie has a title, director, and running time. Declare a Movie variable called favorite, and set its fields equal to the information for your favorite movie.
1
Expert's answer
2013-02-19T07:32:47-0500
// In order to set title and director we should use thefunction // "strcpy" contained in the C-library strings.h. // Therefore we need the next line #include <string.h>
// define the struct struct Movie { chartitle[256]; // title of the film, itis assumed that is has length at most 256 symbols chardirector[128]; // director of the file, it is assumed that is has length at most 128 symbols intrunning_time; // running time inminutes };
int main() { struct Moviefavorite; // declare variable strcpy(favorite.title, "Titanik"); // set title strcpy(favorite.director, "James Cameron"); // set director favorite.running_time = 194; // set running_time
Comments
Leave a comment