Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Project 5, Program Design 1. (60 points) A hashtag is a word or phrase preceded by a hash sign (#), used on social media websites
Project 5, Program Design 1. (60 points) A hashtag is a word or phrase preceded by a hash sign (#), used on social media websites and applications, especially Twitter, to identify messages on a specific topic. Hashtag ends at an invalid hashtag character (any character that is not a letter, digit, or underscore) or the end of the sentence. Write a program to check if a sentence entered by user contains a hashtag. If so, display the hashtag. If not, print a no hashtag message. If there are multiple hashtags in the input, display the first one. Example input/output: Input: Input: More than 130 students messaged us to win an exclusive pair of USF socks last week for #NationalsockDay Output: NationalsockDay Input: More than 130 students messaged us to win an exclusive pair of USF socks last week for National SockDay! Output: No hashtag in the input Input: More than 130 students messaged us to win an exclusive pair of #USF socks last week for #National Sock Day! Output: USF Input: More than 130 students messaged us to win an exclusive pair of USF socks last week for #National SockDay! Output: National SockDay Your program should include the following function: int find_hashtag (char *31, char *s2); Your program should include the following function: int find_hashtag (char *31, char *s2); The find hashtag function expects sl to point to a string containing the input as a string and stores the hashtag to the string pointed by 32. If the input does not contain a hashtag, 52 should contain an empty string. An empty string is a valid string with no characters except the null character. The function returns 1 if the input contains a hashtag, and returns 0 otherwise. 1) Name your program extract_hashtag.c. 2) Assume input is no longer than 1000 characters. 3) The find hashtag function should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the function. 4) strtok and strtok_r functions are not allowed in this program. 5) Library function isalpha(), isdigit(), and isalnum() are allowed in this program. 6) To read a line of text, use the read_line function (the pointer version) in the lecture notes. 2.(40 points) Write a program that accepts as command line arguments the sign of a math operation (+, ; x, or !) and two integer numbers and displays the result of the operation (all integer operations). For example, if the arguments are +, 5, -3, the program should display 2. You may find strcmp function useful Note: x for the multiplication is letter x, not* (* has special meaning to Unix shell.) Sample run: ./a.out - 52 output: 3 1) Name your program command_math.c. 2) Use atoi function in to convert a string to integer form
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started