C infinite loop with linked list -


I am trying to create a program that starts a fantastic link list and then to the user for more data Asks and finally adds them to the list of current links However, my programming is trapped in the infinite loop.

  #include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; Typedef struct link_list {int data; Struct linked_list * Next; } Element; Typeff element * aliphater; Zero addendum (element *, int); Zero cross (ALLIPeter); Int main () {// Create a link list elementptr first = NULL, final = null; Int input, num; Printf ("Please enter the first integer data: \ n"); Scanf ("% d", and input); // Create a linked list with User Initialized Data = (Elementor) malloc (Sagef (Element)); Last = first; Last - & gt; Data = input; Last - & gt; Next = null; Printf ("Please enter the number of numbers you want to add at the end of the linked list \ n"); Scanf ("% d", and number); Additive (& previous, number); Cross (first); Return 0; } Zero addendum (element * L, int number) {int i = 0, extradata; While (i & lt; num) {i ++; Printf ("Please enter a data: \ n"); Scanf ("% d", & extradata); (* L) - & gt; Next = (Elementor) malloc (form (element)); * L = (* l) - & gt; next; (* L) - & gt; Data = extradata; (* L) - & gt; Next = null; } Printf ("Data sets have been added \ n"); } Zero cross (elementptr f) {elementptr current; Int count = 0; Current = f; While (current! = Null) {count ++; Printf ("data is% d \ n", current-> data is); } Printf ("there are% d elements in the linked list \ n", counting); }  

in your code

  while (current ! = Null) {count ++; Printf ("data is% d \ n", current-> data is); }  

You never change the value of current or it starts in the form of a tap and loop is never executed, or This non-faucet starts and the loop proceeds forever.

You must

  current = current-> gt;  

After your printf , advance the next element in the links list.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -