Issues that occur when you create a sequential table

Source: Internet
Author: User

Debug to find out where the problem occurs

#include <stdlib.h> #include "Orderfist.h" status insertlist_sq (SqList l[])/* Insert an element in the list */{int32 i32osm = 1; UINT32 insert_position = 0U, Insert_data = 0U, u32i = 0U, u32j =0u;/* defines an unsigned location for inserting variables, data variables, and loop body variables */i32osm = osm_printf ("Please Lose Enter the position to be inserted (non-negative) and data: ");/* Prompt to enter the place */insert_position = Scanf_for ();/* Input the location to be inserted */insert_data = Scanf_for ();/* Enter the inserted data */l-& gt;u32length++;/* the length of the static table after insertion has been increased by a */for (u32j = l->u32length; u32j > (insert_position-1u), u32j--)/* After the insertion of the position for each The number is moved backward by one using the Loop body */{(L + u32j)->elem = ((L + u32j)-1U)->elem;/* moves the data position after the insertion point backward by one */} ((L + insert_position)-1U)-& Gt;elem = insert_data;/* assigns the input data to the insertion position data, before the insertion position is unchanged */for (u32i = 0U; u32i < l->u32length; u32i++)/* Use the loop body to print the data */{if (0U! = (L + u32i)->elem)/* detects the validity of incoming parameters */{I32OSM = osm_printf ("%d", (l+u32i)->elem);/* All print out */}}return 0U ;}
The l->u32length++; here is always 1 and no value is passed. It's always the same as 0 when it's initialized.

The question now is how to solve the l->u32length++ that will create the function through the assignment of the main function to the insertion function


Use structure pointers as function parameters for efficiency: When you need to protect the data, prevent accidental changes to the pointer const qualifier. Passing structure values is the most common method of handling small structures.






Issues that occur when you create a sequential table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.