-
Notifications
You must be signed in to change notification settings - Fork 205
/
pg270_q009.c
19 lines (18 loc) · 972 Bytes
/
pg270_q009.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
int main (int argc, char* argv[] ){
/* Write an implementation of strncmp.
* Your program reads an int on a line by itself - this is the max number of chars to compare
* Followed by string 1 on a line by itself, terminated by \n
* Followed by string 2 on a line by itself, terminated by \n
* and calls a function that prints
* 0 if at most first n chars of both strings were equal
* -1 if string 1 was smaller while comparing first n chars
* 1 if string 1 was bigger while comparing first n chars
* notion of big or small is same as standard library strncmp function
* do not use library strncmp function
* assume that input strings are <30 chars
* If longer string is presented as input, use only first 29 chars
* Include error checks for the value of n. It should be >0 and <30
* If value of n is outside this range then print output value as -2 instead of above values */
return 0;
}