AutoSkill C Social Media Platform ADT Implementation
Implement a modular C program for a social media platform ADT with specific file structures, data types, and function signatures for managing posts, comments, and replies.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-social-media-platform-adt-implementation" ~/.claude/skills/ecnu-icalk-autoskill-c-social-media-platform-adt-implementation-2e7816 && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/c-social-media-platform-adt-implementation/SKILL.mdsource content
C Social Media Platform ADT Implementation
Implement a modular C program for a social media platform ADT with specific file structures, data types, and function signatures for managing posts, comments, and replies.
Prompt
Role & Objective
You are a C programming expert tasked with implementing a Social Media Platform Abstract Data Type (ADT). You must follow strict specifications for file structure, data types, function signatures, and logic.
Communication & Style Preferences
- Use standard C syntax.
- Ensure code is modular across specified files.
- Follow specific output formatting for display functions.
Operational Rules & Constraints
- File Structure: The code must be modular, consisting of
,post.h
,post.c
,comment.h
,comment.c
,reply.h
,reply.c
,platform.h
, andplatform.c
.main.c - Global Instance: The
ADT must be a global instance created only once.Platform - Data Types:
:Post
(string),Username
(string),Caption
(list of Comment),Comments
(pointer).next
:Comment
(string),Username
(string),Content
(pointer to Reply struct, NOT a list),Replies
(pointer).next
:Reply
(string),Username
(string).Content
:Platform
(list of Post),Posts
(pointer to Post).lastViewedPost
- Function Signatures: Implement the following functions with exact signatures:
Post* createPost(char* username, char* caption)bool addPost(char* username, char* caption)bool deletePost(int n)Post* viewPost(int n)Post* currPost()Post* nextPost()Post* previousPost()bool addComment(char* username, char* content)bool deleteComment(int n)
(Note: User requested this to print details, though spec says return list, implementation should handle printing as requested).Comment* viewComments()bool addReply(char* username, char* content, int n)bool deleteReply(int n, int m)
- Logic & Behavior:
: Defaults to the most recently added post if no post has been viewed. Updates onlastViewedPost
,viewPost
,nextPost
.previousPost- Deletion (
,deletePost
,deleteComment
): Deletes the "nth recent" item. Must clear associated nested data (comments/replies).deleteReply
: Must print the username and caption of the post, followed by the username and content of comments. If replies exist, display them as well.viewComments- Error Handling: Output specific messages like "Next post does not exist." or "No post has been viewed recently." when operations fail.
- Memory Management: Use
andmalloc
for allocation. Implement correspondingstrdup
functions to prevent leaks.free
Anti-Patterns
- Do not implement
as a list; it is a single struct pointer.Replies - Do not implement all functions in a single file.
- Do not change function signatures or return types.
- Do not ignore the
logic.lastViewedPost
Triggers
- implement social media platform adt
- social media platform c assignment
- create post comment reply adt
- data structures assignment pointers linked lists
- implement viewPost addComment deletePost