Question

Assignment3 - Protected View - Saved to this PC ejembi jeremy X File Home Insert DesignLayout References MailingsReview Viewplease can i get the answer for the 3rd question

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

Program:

#include <stdio.h>
#include <string.h>

void main()
{
   int i;
   char line[100], string[100];
   char *searchPtr;
  
   printf("\nEnter the line of text:\n");
   scanf(" %[^\n]s",line);
   printf("\nEnter the search string:\n");
   scanf(" %[^\n]s",string);
  
   int l = strlen(string);
  
   searchPtr = strstr(line, string);
   if( searchPtr )
   {
       printf("\nFirst time: \nRemainder string: %s\n",searchPtr);
       searchPtr = strstr(searchPtr+l, string);
       if( searchPtr )
       {
           printf("\nSecond time: \nRemainder string: %s\n\n",searchPtr);
       }
       else
       {
           printf("\nSecond time not found\n\n");
       }
   }
   else
   {
       printf("\nFirst time not found\n\n");
   }
}


Execution and Output:

terminal-> gcc -o stringsearch stringsearch.c terminal-> ./stringsearch Enter the line of text: hello world!! hello universe!

Add a comment
Know the answer?
Add Answer to:
Assignment3 - Protected View - Saved to this PC ejembi jeremy X File Home Insert DesignLayout Ref...
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
  • Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...

  • Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to 3) who sell five different products (0 to 4). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following: a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...

  • ho, then print the message "Next flight leaves in 3 hours." 6.22 Total Sales) Use a...

    ho, then print the message "Next flight leaves in 3 hours." 6.22 Total Sales) Use a two-dimensional array to solve the following problem. A company has four salespeople (I to 4) who sell five diferent products (I to 5). Once a day, each salesperson pases in a slip for each different type of product sold. Each slip contains: a) b) c) The salesperson numbor The product number The total dollar value of that product sold that day Thus, each salesperson...

  • AutoSave ExcelTemplateAssignment Cho1 (1) - Protected View Ex. File Home Insert Draw Page Layout Formulas Data...

    AutoSave ExcelTemplateAssignment Cho1 (1) - Protected View Ex. File Home Insert Draw Page Layout Formulas Data Review View Нelp QuickBooks O PROTECTED VIEW Be careful-files trom the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. Enable Editing G35 1 P1-4A Prepare a cost of goods manufactured schodule, a partial income statement, and a partial balance sheet 2. 3 The following data were taken from the records of Clarkson Company for the fiscal...

  • AutoSave OB A S ExcelTemplateAssignment.ChO2 (1) · Protected View - Excel Search ile Home Insert Page...

    AutoSave OB A S ExcelTemplateAssignment.ChO2 (1) · Protected View - Excel Search ile Home Insert Page Layout Formulas Data Review View Help DYMO Label QuickBooks PROTECTED VIEW Be careful--files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View Enable 1 . 1 X E 2-9 Prepare a cost of goods manufactured schedule and partial financial statements 1 A B C D E F G H I J K E2-9 Prepare a...

  • Autent %* Excellerplignment, CNT). Protected in File Home insert Draw Page Layout Formulas Data Review View...

    Autent %* Excellerplignment, CNT). Protected in File Home insert Draw Page Layout Formulas Data Review View Help Quichols FOLLCHED VW Be careful files from the more con contain viruses. Une you need to det e to vay in Protected View Enable Iding xo CD GHKLMNL01 1 E1-12 Prepare a cost of goods man actured schedule and a partial income statement 2 Cepeda Corporation has the following cost records for June 2017 Indirect factory labor $4,500 Factory ilities $400 Direct materials...

  • AutoSave 01 R 2 ExcelTemplateAssignment_Cho2 (1) . Protected View - Excel O Search File Home Insert...

    AutoSave 01 R 2 ExcelTemplateAssignment_Cho2 (1) . Protected View - Excel O Search File Home Insert Page Layout Formulas Data Review ViewH elp DYMO Label QuickBooks PROTECTED VIEW Be careful--files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. Enat X fr P2-3A Prepare entries for a job order cost system and cost of goods manufactured schedule 24. A B C D E F G H I J 1 [P2-3A Prepare...

  • AutoSave CH 2 ExcelTemplateAssignment CO2 (1) - Protected View Excel Search File Home Insert Page Layout...

    AutoSave CH 2 ExcelTemplateAssignment CO2 (1) - Protected View Excel Search File Home Insert Page Layout Formulas Data Review View Help DYMO Label QuickBooks O PROTECTED VIEW Be careful--files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View 114 X vf 4. A B C D 1 P2-5A Analyze manufacturing accounts and determine missing amounts 2 Phillips Corporation's fiscal year ends on November 30. The following accounts are found in its...

  • | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l U...

    | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l Unless you need to edit, it's safer to stay in 11. Write C++ statements that do the following: a. Declare an array alpha of 10 rows and 20 columns of type int. b. Initialize the array alpha to 0. c. Store 1 in the first row and 2 in the remaining rows d. Store 5 in the first column, and make...

  • 210 Excel Inventory Valuation Spreadsheet Fall 19 [Protected View] Microsoft Excel X File Page Layout Formulas Data Rev...

    210 Excel Inventory Valuation Spreadsheet Fall 19 [Protected View] Microsoft Excel X File Page Layout Formulas Data Review View Home Insert iProtected View This file originated from an Internet location and might be unsafe. Click for more details Enable Editing fr A8 В C D Е F G J K м O р 1 2 Excel Project Pt2: Inventory Valuation Methods The assumptions are provided at the top of the Calculations worksheet. In making the calculations in each step link...

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