Xmipp  v3.23.11-Nereus
Functions
lib_std.cpp File Reference
#include "situs.h"
#include "lib_std.h"
#include "lib_err.h"
Include dependency graph for lib_std.cpp:

Go to the source code of this file.

Functions

int readln_int ()
 
double readln_double ()
 
void removespaces (char *file_name, unsigned fl)
 
char readln_char ()
 

Function Documentation

◆ readln_char()

char readln_char ( )

Definition at line 80 of file lib_std.cpp.

81 {
82  char cx;
83  int ch;
84  const char *program = "lib_std";
85 
86  if (scanf("%c", &cx) == EOF) {
87  error_EOF(14050, program);
88  }
89  for (; ;) {
90  ch = getchar();
91  if (ch == EOF) {
92  error_EOF(14060, program);
93  }
94  if (ch == '\n') break;
95  }
96  return ((char)cx);
97 }
void error_EOF(int error_number, const char *program)
Definition: lib_err.cpp:101

◆ readln_double()

double readln_double ( )

Definition at line 38 of file lib_std.cpp.

39 {
40  double ddx;
41  int ch;
42  const char *program = "lib_std";
43 
44  if (scanf("%le", &ddx) == EOF) {
45  error_EOF(14030, program);
46  }
47  for (; ;) {
48  ch = getchar();
49  if (ch == EOF) {
50  error_EOF(14040, program);
51  }
52  if (ch == '\n') break;
53  }
54  return ((double)ddx);
55 }
void error_EOF(int error_number, const char *program)
Definition: lib_err.cpp:101

◆ readln_int()

int readln_int ( )

Definition at line 19 of file lib_std.cpp.

20 {
21  int i, ch;
22  const char *program = "lib_std";
23 
24  if (scanf("%d", &i) == EOF) {
25  error_EOF(14010, program);
26  }
27  for (; ;) {
28  ch = getchar();
29  if (ch == EOF) {
30  error_EOF(14020, program);
31  }
32  if (ch == '\n') break;
33  }
34  return i;
35 }
void error_EOF(int error_number, const char *program)
Definition: lib_err.cpp:101
#define i

◆ removespaces()

void removespaces ( char *  file_name,
unsigned  fl 
)

Definition at line 58 of file lib_std.cpp.

59 {
60  int i;
61 
62  file_name[fl - 1] = '\0';
63 
64  /* remove leading space */
65  for (;;) {
66  if (file_name[0] == ' ') {
67  for (i = 1; i < (int)fl; ++i) file_name[i - 1] = file_name[i];
68  --fl;
69  } else break;
70  }
71 
72  /* remove trailing white space */
73  for (i = 0; i < (int)fl; ++i) if (file_name[i] == '\n' || file_name[i] == ' ') {
74  file_name[i] = '\0';
75  break;
76  }
77 }
#define i