Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // for strchr()
int my_input(char *Astring, int max_length)
{
char *inputPosition = NULL;
// read the text entered by the user
if (fgets(Astring, Alength, stdin) != NULL) // no user input error ?
{
inputPosition = strchr(Astring, '\n'); // looking for "return"
if (inputPosition != NULL) // end of line found
{
*inputPosition = '\0'; // On remplace ce caractère par \0
}
return 1; // no error
}
else
{
return 0; // error !
}
}
int main()
{
char YourName[10];
printf("what's your name ? ");
my_input(YourName, 10);
printf("Your name is %s !\n\n", YourName);
return 0;
}
I do not look specifically for a fgets, with stream support, just something that will do the job.
for asm, I am out : noob inside.
in c, ok, but how. get the char, print it, and block input when max_length is reached ok. I don't feel comfortable enough to do it. mainly when the del key is used to delete a mistake