Question

1. If you are going to compile a main.cpp, while your main() in main.cpp uses a...

1. If you are going to compile a main.cpp, while your main() in main.cpp uses a function defined in another file funcdef.cpp, which of the following command is correct?

A) g++ main.cpp funcdef.cpp -o func

B) g++ funcdef.cpp main.cpp -o func

C) g++ main.cpp -o func

D) g++ main.cpp -o funcdef.cpp func

2. What is argv[0]?

A) This syntax is illegal

B) The first argument to the program

C) The name of the program

D) The number of arguments to the program

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The correct option is D) g++ main.cpp -o funcdef.cpp func

Explanation: If we are going to compile a main.cpp, while our main() in main.cpp uses a function defined in another file funcdef.cpp, the command which is correct is g++ main.cpp -o funcdef.cpp func. This is because the base command for the Gnu C++ compiler is "g++".

For example :

g++ main.cpp

This command is responsible for creating an executable program.

2.

The correct option is C) The name of the program

Explanation: argv[0] is the command line argument which is responsible for holding the name of the program.

Add a comment
Know the answer?
Add Answer to:
1. If you are going to compile a main.cpp, while your main() in main.cpp uses a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Objective: Use input/output files, strings, and command line arguments. Write a program that processes a text...

    Objective: Use input/output files, strings, and command line arguments. Write a program that processes a text file by removing all blank lines (including lines that only contain white spaces), all spaces/tabs before the beginning of the line, and all spaces/tabs at the end of the line. The file must be saved under a different name with all the lines numbered and a single blank line added at the end of the file. For example, if the input file is given...

  • 1. Suppose you wrote a program that reads data from cin. You are now required to...

    1. Suppose you wrote a program that reads data from cin. You are now required to reimplement it so that you can read data from a file. You are considering the following changes. I. Declare an ifstream variable in_file II. Replace all occurrences of cin with in_file III. Replace all occurrences of > > and get_line with the appropriate operations for ifstream objects What changes do you need to make? I, II, and III II and III I and III...

  • I am using xcode Use the following ideas to develop a nonrecursive, linear-time algorithm for the...

    I am using xcode Use the following ideas to develop a nonrecursive, linear-time algorithm for the maximum-subarray problem. Start at the left end of the array, and progress toward the right, keeping track of the maximum subarray seen so far. Knowing a maximum subarray of A[1..j], extend the answer to find a maximum subarray ending at index j + 1 by using the following observation: a maximum subarray of A[1..j + 1] is either a maximum subarray of A[1..j] or...

  • Problem: Write a program that behaves as described below.If the first command-line argument after the program...

    Problem: Write a program that behaves as described below.If the first command-line argument after the program name (argv[1]) is “--help”, print the usage information for the program. If that argument is not “--help”, you are to expectargv[1]and subsequent arguments to be real numbers(C, integer, float, or double types)in formats acceptable to the sscanf()function of the C library or strings of ASCII chars that are not readable as real numbers. You are to read the numbers, count them and calculate the...

  • 1. Specification Write a C program to implement a simple calculator that accepts input in the...

    1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...

  • So on this assignment... I have the main.cpp file, the fan.cpp file, and the fan.h file...

    So on this assignment... I have the main.cpp file, the fan.cpp file, and the fan.h file created and open in Dev C++. However, every time I try to compile I get a series of undefined reference to errors. Any advice is much appreciated!!! (45 pts) Work Programming Exercise 9.2 (class Fan) in the textbook on page 367. Additional specifications: • Use separate header and implementation files. • The main program (not the functions) should display the values of Speed, On,...

  • Consider the following function://To compile this code by itself, naturally you need a main method. #include...

    Consider the following function://To compile this code by itself, naturally you need a main method. #include <stdio.h> #include <sys/stat.h> void printFileIndexNumber(char *path){ struct stat statbuf; if (stat(path, &statbuf) == -1) perror("Failed to get file status"); else printf("%s inode number is %d", path, &statbuf.st_ino);} It uses the stat system call to get information about the file indicated by the parameter *path. It puts the information about the file in the structure struct stat statbuf and prints out the file index number/inode...

  • **Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of...

    **Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of your own design. The class should contain a protected int member variable var, which is initialized with an integer value between 1 and 50 in a constructor that takes an integer parameter. The class should contain a public member function called playthat should print out a sequence of integers as a result of iteratively applying a math function f to the member variable var...

  • C programming The program will require the following structure: struct _data { char *name; long number;...

    C programming The program will require the following structure: struct _data { char *name; long number; }; The program will require command line arguments: int main(int argv, char **argc) { Where argv is the number of arguments and argc is an array holding the arguments (each is a string). Your program must catch any case where no command line arguement was provided and print a warning message (see below). You MUST include/use the following functions, defined as follows: int SCAN(FILE...

  • The question asks you to assume that your input file is an English text that may...

    The question asks you to assume that your input file is an English text that may contain any character that appears on keyboard of a computer. The task is to read each character from the input file and after encrypting it by adding an integer value n (0 < n < 128) to the character, to write the encrypted character to output file. We are supposed to use command line arguments and utilize argc, and argv parameters in main function...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT