I am working on a school project in which we have to do some operations (select, min, max) on a table saved in .txt file. The problem is that we can\'t use common functions
There are few ways to acomplish this.
I guess the teacher wants this method in particular. The idea is reading standard input rather than particular file. In C++ you can simply read the stdin object. Here's an example:
#include
#include
int main(void)
{
char str[80];
int i;
printf("Enter a string: ");
fgets(str, 10, stdin);
/* remove newline, if present */
i = strlen(str)-1;
if( str[ i ] == '\n')
str[i] = '\0';
printf("This is your string: %s", str);
return 0;
}
Source: http://www.java2s.com/Code/C/Console/Usefgetstoreadstringfromstandardinput.htm
You can call "type" util @ Windows (not sure about it) or "cat" util in Linux as a subprocess to read some partticular file. But this is rather a "hack", so I do not recommend using this one.