Skip to content

Commit

Permalink
Refactor display_help function to use printfNewLine for each command
Browse files Browse the repository at this point in the history
  • Loading branch information
chethanyadav456 committed Sep 21, 2024
1 parent 1406f26 commit 90f989b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\gcc\\bin\\gcc.exe",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"ws2tcpip.h": "c"
}
}
18 changes: 13 additions & 5 deletions cmd_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#pragma comment(lib, "Ws2_32.lib") // Link with Winsock library

void printfNewLine(char *str);

void ipaddr()
{
printf("IP ADDRESS: 192.12.345.23\n");
Expand Down Expand Up @@ -53,9 +55,15 @@ int hostname()

void display_help()
{
printf("Available commands:\n");
printf(" ipaddr - Display the IP address\n");
printf(" help - Show this help message\n");
printf(" hostname - Display the hostname\n");
printf(" exit - Exit the program\n");
printfNewLine("Available commands:");
printfNewLine(" ipaddr - Display the IP address");
printfNewLine(" help - Show this help message");
printfNewLine(" hostname - Display the hostname");
printfNewLine(" exit - Exit the program");
}

void printfNewLine(char * str)
{
printf("%s\n", str);
}

1 change: 1 addition & 0 deletions cmd_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
void ipaddr();
int hostname();
void display_help();
void printfNewLine(char *str);

#endif // CMD_FUNCTIONS_H

0 comments on commit 90f989b

Please sign in to comment.