submition4
This commit is contained in:
parent
715ea2777a
commit
85bc7c5389
12
a1/program.c
12
a1/program.c
@ -12,7 +12,10 @@ int main()
|
|||||||
{
|
{
|
||||||
link* pointer_to_start_of_chain = malloc(sizeof(link));
|
link* pointer_to_start_of_chain = malloc(sizeof(link));
|
||||||
memset(pointer_to_start_of_chain,0,sizeof(link));
|
memset(pointer_to_start_of_chain,0,sizeof(link));
|
||||||
reading_strings_and_storing_them_in_memory(pointer_to_start_of_chain);
|
int read_lines = reading_strings_and_storing_them_in_memory(pointer_to_start_of_chain);
|
||||||
|
if(read_lines==0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int result=0;
|
int result=0;
|
||||||
link* next_link = pointer_to_start_of_chain;
|
link* next_link = pointer_to_start_of_chain;
|
||||||
while(next_link != NULL){
|
while(next_link != NULL){
|
||||||
@ -32,14 +35,15 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reading_strings_and_storing_them_in_memory(link* pointer_to_start_of_chain){
|
int reading_strings_and_storing_them_in_memory(link* pointer_to_start_of_chain){
|
||||||
link* next_link = pointer_to_start_of_chain;
|
link* next_link = pointer_to_start_of_chain;
|
||||||
char buffer[SIZE];
|
char buffer[SIZE];
|
||||||
link* ancestor=NULL;
|
link* ancestor=NULL;
|
||||||
|
int counter=0;
|
||||||
while(1){
|
while(1){
|
||||||
if(fgets(buffer, SIZE, stdin)==NULL||buffer[0]=='\n'){
|
if(fgets(buffer, SIZE, stdin)==NULL||buffer[0]=='\n'){
|
||||||
|
free(next_link);
|
||||||
if(ancestor!=NULL){
|
if(ancestor!=NULL){
|
||||||
free(ancestor->p_na_next_struct);
|
|
||||||
ancestor->p_na_next_struct=NULL;
|
ancestor->p_na_next_struct=NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -53,7 +57,9 @@ void reading_strings_and_storing_them_in_memory(link* pointer_to_start_of_chain)
|
|||||||
memcpy(next_link->p_na_line, buffer,size);
|
memcpy(next_link->p_na_line, buffer,size);
|
||||||
ancestor=next_link;
|
ancestor=next_link;
|
||||||
next_link=next_link->p_na_next_struct;
|
next_link=next_link->p_na_next_struct;
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
|
return counter;
|
||||||
}
|
}
|
||||||
int analizing_string(char* pointer){
|
int analizing_string(char* pointer){
|
||||||
float number1, number2, result3;
|
float number1, number2, result3;
|
||||||
|
Loading…
Reference in New Issue
Block a user