redesign of alg

This commit is contained in:
mpabi 2024-05-22 18:51:39 +00:00
parent 0664e93e2a
commit a40d924408
1 changed files with 16 additions and 18 deletions

View File

@ -31,34 +31,32 @@ char *alloc(int n)
return 0;
}
// def. model danych
//funkcja lokuje pamiec dla kazdego slowa.
//
//wskaznik p1 wskazuje na pierwsza litera slowa,
//liczy ilosc slowa i alokuje pamiec dla niego.
//pre processor
#define LEN (8+2)*10
struct model {
char * str;
uint32_t len ;
};
void alg (char *s) {
//func alg
//in: ptr to date
//return: count of words
int alg (const char * ptr) {
char count;
for (int8_t c = 0; c <= strlen(s); c++) {
if (s[c] != 0x20 && s[c] != '\0') {
count++;
} else {
char *p1 = &s[++c];
alloc (count);
count = 0;
}
}
return 1;
}
int main() {
char *str = "If wantered relation no surprise of all";
alg(str);
struct model * ptr = (struct model *) alloc (LEN);
return 1;