Answer All Questions: Q 1 Find Occurrences
Answer All Questions: Q 1 Find Occurrences
Q1 Find Occurrences
Name:
focc <string> <substring>
Description:
• This command should search for the given substring in string and then
return the number of occurrences of this substring if found or zero if not
found.
• <string> is sample statement
• <substring> contains a character or more that we need to find the number
of its occurrences in <string>
Notes:
• The given string contains multiple words separated by underscore; i.e. the
underscore acts here exactly as if spaces exist between words
• The substring is not necessary be exist in the given string and in this case
return 0
Example:
FOS> focc hello_world ld ➔ 1 (hello_world)
FOS> focc hello_world l ➔ 3 (hello_world)
FOS> focc hello_world_o_w o_w ➔ 2 (hello_world_o_w)
FOS> focc hellohellohellohello lo ➔ 4 (hellohellohellohello)
FOS> focc operating_systems ss ➔ 0 (Not exist)
FOS> focc defenselessness ss ➔ 2 (defenselessness)
FOS> focc ppppppp pp ➔ 3 (ppppppp)
Page 1 of 5
Function:
Your code MUST be written inside the following function:
Page 2 of 5
Function:
Your code MUST be written inside the following function:
Helper Functions:
• strcmp(const char *p, const char *q): to compare string p to string q
Evaluation:
a) Correct code logic [2 marks]
b) Successful run [3 marks]
Page 3 of 5
Evaluation:
a) Correct code logic [2 marks]
b) Successful run [3 marks]
Page 4 of 5
Return:
3. number of modified pages in the given range
Helper:
1. You may need to use PERM_MODIFIED
2. There's a constant in the code called "PAGE_SIZE" which equal to
4KB
3. You can use "ROUNDDOWN" and "ROUNDUP" functions, described
below in order to round the virtual addresses on multiple of
PAGE_SIZE (4 KB)
Evaluation:
a) Correct code logic [2 marks]
b) Successful run [3 marks]
Page 5 of 5