This commit is contained in:
mpabi 2024-05-23 08:46:15 +00:00
parent 6836e07a9b
commit 8bf97ca90b
1 changed files with 28 additions and 11 deletions

View File

@ -65,15 +65,13 @@ char *simple_strtok(char *str, const char *delims) {
static char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu
// Jeśli przekazano nowy ciąg, zaktualizuj static_str
if (str != NULL) {
static_str = str;
}
// Jeśli static_str jest NULL, zwróć NULL
if (static_str == NULL) {
return (char *) NULL;
if (str == NULL) {
return (char *) NULL; // str nie wskazuje na zdanie !!!
}
static_str = str;
// " .,mpabi"
// ^
// Pomiń początkowe delimitery
while (*static_str && is_delim(*static_str, delims)) {
static_str++;
@ -102,6 +100,9 @@ char *simple_strtok(char *str, const char *delims) {
return token_start;
}
char buf[100];
struct model * p = (struct model *) buf; //p[1]
////func alg
//in: ptr to date
//return: count of words
@ -115,19 +116,32 @@ int alg (const char * ptr) {
int8_t count = 0;
char *token = simple_strtok(bufer, delims);
while (token != (char *)NULL) {
while (token != (char *)NULL) {
p[count].str = token;
p[count].len = strlen(token);
token = simple_strtok((char *)NULL, delims);
count++;
token = simple_strtok((char *)NULL, delims);
}
return count;
}
/*
struct model {
char * str;
uint32_t len ;
} tab [10] ;
*/
int main() {
char *str = "If wantered relation no surprise of all";
struct model *ptr = (struct model *) alloc(LEN);
/*
struct model *ptr = (struct model *) alloc(LEN);
if (ptr != (struct model *)NULL) {
ptr->str = alloc(strlen((char *)str) + 1);
if (ptr->str != (char *)NULL) {
@ -137,6 +151,9 @@ int main() {
int8_t count = alg(ptr->str);
}
}
*/
alg(str);
asm ("nop");
return 1;
}