Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 2E
Locate the system header files < , < ,and < on your system (on Unix systems, look inside the / directory). Examine die files to see what’s in them.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In UNIX, how would you remove the directory test and all files and subdirectories
(recursively) in it? The directory test is located in (is a subdirectory of)
/home/myid/smith/projects.
O rmdir /home/myid/smith/projects/test
O rmdir -r /home/myid/smith/projects/test
rm -r /home/myid/smith/projects/test
O rm -r projects/test
Write the C or C++ program system2 that reads, when being executed, OS commands via the "command line parameter" C/C++ feature, and then executes them. The
command line parameters must be legal Unix/Linux commands. Print the number of commands entered. To prepare, read about argc, argv, and envp. Focus is only argc and
argv. A sample execution by fictitious user "mike" is:
herb$ ./a.out pwd ls whoami
argc
4
pwd
argv[1]
Executing command
/Users/mikey
'pwd'
= ls
argv[2]
Executing command 'ls'
Applications
Contacts
Music
Pictures
familie
herb
Downloads
testl
Favorites
Library
Movies
testl.c
pix_low_2020 test2
test2.c
Desktop
Public
Documents
a.out
test.c
argv[3] = whoami
Executing command
mikey
'whoami'
Implement a simple version of the linux cat command in C++. Use the system calls open(), get() and close().
cat - reads a file as specified by the user and prints its contents. A typical usage is as follows:
If from my terminal y run ./cat main.cpp
the contents of main.cpp. will be printed.
Your program cat can be invoked with one or more files on the command line; it should just print out each file in turn. Example:
[terminal]$ ./cat main.cpp main2.cpp #include <iostream>using namespace std;int main(){cout << "Hello, World!"; return 0;}#include <iostream>using namespace std;int main(){cout << "Programming is great fun!";return 0;}
As you can see content of main.cpp was printed first and the content of main2.cpp
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Describe two properties that each candidate key must satisfy.
Modern Database Management (12th Edition)
In what year was Plankalkl designed? In what year was that design published?
Concepts of Programming Languages (11th Edition)
Which of the following activities require real-time processing? a. Printing mailing labels b. Playing a compute...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Write an SQL statement to display the breed, type, and DOB of all pets having the type Dog.
Database Concepts (8th Edition)
In pseudocode, this statement causes a function to end and sends a value back to the part of the program that c...
Starting Out with Programming Logic and Design (4th Edition)
Explain the difference between redundancy and diversity.
Software Engineering (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Hi. Can anyone help me change filenames in a directory based on a list in a test file (filenames,txt)? Prefer Python code, but Awk, or bash will do. Thank youarrow_forwardImplement a simple version of the linux grep command in C++. grep - Looks through a file, line by line, trying to find a user-specified search term in the line. If a line has the word within it, the line is printed out, otherwise it is not. Use the system calls open(), getline(), close(). Requirements (examples run from. terminal) Your program grep is always passed a search term and zero or more files to grep through (thus, more than one is possible). It should go through each line and see if the search term is in it; if so, the line should be printed, and if not, the line should be skipped. [terminal]$ ./grep ! main.cpp main2.cppcout << "Hello, World!";cout << "Programming is great fun!"; The matching is case sensitive. Thus, if searching for world, lines with World will not match. Lines can be arbitrarily long (that is, you may see many many characters before you encounter a newline character, \n). grep should work as expected even with very long lines. For this,…arrow_forwardWith your knowledge in the file, systems write a javaprograms the can be used to: i. ii. iii. Create a fileMove a file to another directoryRename a file in a directoryarrow_forward
- select the python loop that prints directory names, subdirectories, and files in the path. for dirname, subdirs, files in os.walk(path): print(dirname, subdirs, files) fordirname,subdirs,filesinos.path(path):print(dirname,subdirs,files) forfilesinos.path(path):print(files) fordirnameinos.walk(path):print(dirname[0],dirname[1],dirname[2])arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. Hello, I am trying to make a program that prints the contents of a file but whenever I try to run it, it just prints a bunch of question marks infinitely and this only happens when I run it on a UTM virtual machine(Linux terminal). It works fine when I run it on my Mac terminal so I am not sure if it has to do with the virtual machine or my program. Please help!! Image 1: cat.c Image 2: input.txt Image 3: output/resultsarrow_forwardIn C++ can someone make a code where it prompts me to login. But it has to grab a txt file and reads user name and password separated with a comma and once inputted in a code it will let me know it was successful.arrow_forward
- Need help to implement networking in python Server.py Load data from file This option will ask the user for a fully qualified path and will load a JSON file containing the information for users and pending messages. The format of the JSON file will be defined based on your implementation and it will the same used to save the data into file (menu option #4). Functionalities the server must provide: 1) User Sign Up: adds a user identified by a phone number to the system. a) Protocol: USR|username|password|display_name b) Response: 0|OK for success. 1| for an error. c) The server should validate that the username does not exist 2) User Sign In: verify user credentials a) Protocol: LOG|username|password b) Response: i) 0|OK → the credentials are correct. ii) 1|Invalid Credentials iii) 2|Already Logged In → in case that the user is logged in from another client. c) This will help the server knowing which user is connected. d) The server should keep a list of connected clients, which should…arrow_forwardYour ReadRoomFile program reads a room file. Is it possible to tell how many rooms are in the file from the file size? Explain why or why not?arrow_forwardA student launches the Python interpreter from his home directory. His home directory contains another directory called 'mydir', and 'mydir' contains two files called 'foo' and 'bar'. The home directory does not contain any files, only other directories. What will happen when he writes the following code at the Python prompt: >>> import os >>> filenames = os.listdir('mydir') >>> f= open(filenames[0]) ===================================================================================== A variable f representing a file object will be created, and the first file in the directory 'mydir' will be opened for writing in text mode. An error will be produced stating that the file to be opened does not exist. An error will be produced stating that filename is not subscriptable. A variable f representing a file object will be created, and the first file in the directory 'mydir' will be opened.arrow_forward
- implementation of Caesar Cipher:You are required to implement the Caesar Cipher encryption/decryption algorithm in Python. Remember to implement the algorithm in such a way that it takes a file as input, encrypts it and store in the current directory. This encrypted file must checkable. The implementation must have a decryption procedure which takes the encrypted file from the current directory, decrypts it and store it with some specific name in the current directory. The name should be different from the original file so that it can be verified.arrow_forwardWrite a set of instructions that, given an initialised variable fileName, creates a file with the name given by fileName and a single line that says "This Is File:" followed by the file's name. Check that the data saved to the file has been removed from the buffer and that all system resources used by these lines have been released. (Don't worry about cases; just assume they're taken care of somewhere else.)arrow_forwardUsing a UNIX environment, write a program in C++ that will: Open a directory "/home/timapple/" and step through each individual directory. Determine file type and display it along with the name of the file. Just provide the relevant code segment in a POSIX compliant system.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License