SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Gets.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 char * Gets ( char * str, int num )
19 {
20 fgets(str, num, stdin);
21 if (str[0]=='\n' || str[0]=='\r')
22 str[0]=0;
23
24 size_t len=strlen(str);
25 if (len>0 && (str[len-1]=='\n' || str[len-1]=='\r'))
26 str[len-1]=0;
27 if (len>1 && (str[len-2]=='\n' || str[len-2]=='\r'))
28 str[len-2]=0;
29
30 return str;
31 }
32
33 #ifdef __cplusplus
34 }
35 #endif