提交 964d2710 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 710d6deb
#ifndef SEQSTRING_H_ #ifndef SEQSTRING_H_
#define SEQSTRING_H_ #define SEQSTRING_H_
// //
// Include the C standard library header file here // Include the C standard library header file here
// //
#include <stdio.h> #include <stdio.h>
// //
// Other header files are included here // Other header files are included here
// //
// //
// Define the data structure here // Define the data structure here
// //
#define MAX_LENGTH 20 // The maximum length of a string #define MAX_LENGTH 20 // The maximum length of a string
typedef struct { typedef struct SeqStrElem
char data[MAX_LENGTH]; // An array is used to store the characters in a string, and the maximum length of the array is the maximum length of the string. {
int nLength; // The actual length of the string, the number of characters in the array. // An array is used to store the characters in a string,
// and the maximum length of the array is the maximum length of the string.
char data[MAX_LENGTH];
// The actual length of the string, the number of characters in the array.
int nLength;
}SeqString; }SeqString;
// //
// Declare the function here // Declare the function here
// //
int InsertBefore(SeqString* pSource, int pos, SeqString* pTarget); int InsertBefore(SeqString* pSource, int pos, SeqString* pTarget);
#endif /* SEQSTRING_H_ */ #endif /* SEQSTRING_H_ */
...@@ -36,9 +36,9 @@ int main(int argc, char* argv[]) ...@@ -36,9 +36,9 @@ int main(int argc, char* argv[])
// Inserts the destination string into the source string // Inserts the destination string into the source string
// //
InsertBefore(&Source, 4, &Target); InsertBefore(&Source, 4, &Target);
InsertBefore(&Source, 15, &Target); // Failed to insert. The insertion position is invalid. InsertBefore(&Source, 15, &Target); // Failed to insert. The insertion position is invalid.
for(i = 0; i < Source.nLength; i++) for (i = 0; i < Source.nLength; i++)
{ {
printf("%c ", Source.data[i]); printf("%c ", Source.data[i]);
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论