MCPcopy Create free account
hub / github.com/WheretIB/nullc / ReadTextFromConsole

Function ReadTextFromConsole

NULLC/includes/io.cpp:96–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 }
95
96 int ReadTextFromConsole(NULLCArray data)
97 {
98 char buffer[2048];
99
100 InitConsole();
101 if(fgets(buffer, 2048, stdin))
102 {
103 char *pos = strchr(buffer, '\n');
104 if(pos)
105 *pos = '\0';
106 }
107 unsigned int len = (unsigned int)strlen(buffer) + 1;
108 char *target = data.ptr;
109 for(unsigned int i = 0; i < (data.len < len ? data.len : len); i++)
110 target[i] = buffer[i];
111 buffer[data.len-1] = 0;
112
113 return ((unsigned int)len < data.len ? len : data.len);
114 }
115
116 void WriteToConsoleExact(NULLCArray data)
117 {

Callers

nothing calls this directly

Calls 2

InitConsoleFunction · 0.85
strchrFunction · 0.85

Tested by

no test coverage detected