1-A U.S. social security number consists of a string of 9 digits, such as “444422333”. Declare a char array named ssn suitable for storing a social security number as a C-string, and write a statement that reads in the next 9 characters of standard input into this array. (Assume that the input consists of one big sequence of digits without spaces or newlines.) 2- Given the availability of an ofstream object named output , and a string variable name tweet , write the other statements necessary to open a file named mytweet” , display the prompt tweet: and then read an entire line into tweet and then write it out to the file mytweet. (Do not define a main function.) 3-Assume that a , b and c are char variables has been declared. Write some code that reads in the first character of the next line into a , the first character of the line after that into b and the first character of the line after that into c . Assume that the lines of input are under 100 characters long. 4-Assume that c is a char variable has been declared. Write some code that reads in the first character of the next line into c . Assume that the lines of input are under 100 characters long. 5-Write the definition of a function named fscopy . This function can be safely passed two fstream objects, one opened for reading, the other for writing. Assume that the input source is a text file consisting of a sequence of newline character-terminated lines. The function simply copies, line by line, the entire content of the data source associated with the first argument to the data target associated with the second argument. No value is returned.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *