redesign of alg
This commit is contained in:
parent
0664e93e2a
commit
a40d924408
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue