<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Olalekan Omotayo</title>
    <description>The latest articles on DEV Community by Olalekan Omotayo (@drazen911).</description>
    <link>https://dev.to/drazen911</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1056265%2F4851e8a4-07dc-4828-9bf6-26f7438a1061.jpeg</url>
      <title>DEV Community: Olalekan Omotayo</title>
      <link>https://dev.to/drazen911</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drazen911"/>
    <language>en</language>
    <item>
      <title>Parsing user input to separate commands and arguments</title>
      <dc:creator>Olalekan Omotayo</dc:creator>
      <pubDate>Fri, 31 Mar 2023 16:16:41 +0000</pubDate>
      <link>https://dev.to/drazen911/parsing-user-input-to-separate-commands-and-arguments-36l</link>
      <guid>https://dev.to/drazen911/parsing-user-input-to-separate-commands-and-arguments-36l</guid>
      <description>&lt;p&gt;Here's an example code in C language for parsing user input to separate commands and arguments:&lt;/p&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;h1&gt;
  
  
  define MAX_ARGS 10
&lt;/h1&gt;

&lt;p&gt;int main() {&lt;br&gt;
    char input[100];&lt;br&gt;
    char *token;&lt;br&gt;
    char *args[MAX_ARGS];&lt;br&gt;
    int arg_count = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(1) {
    arg_count = 0;

    printf("Enter a command: ");
    fgets(input, 100, stdin);

    // Tokenize input string by whitespace
    token = strtok(input, " \n");

    // Parse arguments and store in args array
    while(token != NULL &amp;amp;&amp;amp; arg_count &amp;lt; MAX_ARGS) {
        args[arg_count++] = token;
        token = strtok(NULL, " \n");
    }

    // Check for empty input
    if(arg_count == 0) {
        continue;
    }

    // Print command and arguments
    printf("Command: %s\n", args[0]);
    printf("Arguments: ");
    for(int i=1; i&amp;lt;arg_count; i++) {
        printf("%s ", args[i]);
    }
    printf("\n");
}

return 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;In this code, we first declare a character array input with a size of 100, which we will use to store the user's input. We also declare a character pointer token to represent each individual token in the input string, and an array of character pointers args to store the parsed arguments. We also set a constant MAX_ARGS to limit the number of arguments.&lt;/p&gt;

&lt;p&gt;Within the loop, we use the printf function to display the prompt "Enter a command: " to the user. We then use the fgets function to read the user's input from the standard input stream stdin and store it in the input array.&lt;/p&gt;

&lt;p&gt;We then use the strtok function to tokenize the input string by whitespace and newline characters. The strtok function takes two arguments: the string to tokenize and a string containing the delimiters to use. In this case, we use whitespace and newline characters as delimiters.&lt;/p&gt;

&lt;p&gt;We then loop through each token and store it in the args array, incrementing the arg_count variable to keep track of the number of arguments. We also use a check to ensure that we don't exceed the maximum number of arguments.&lt;/p&gt;

&lt;p&gt;After parsing the arguments, we check for empty input and continue to the next iteration of the loop if no arguments were entered. Otherwise, we print the command and arguments using the printf function.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Reading user input and displaying a prompt code in c language</title>
      <dc:creator>Olalekan Omotayo</dc:creator>
      <pubDate>Fri, 31 Mar 2023 16:03:51 +0000</pubDate>
      <link>https://dev.to/drazen911/reading-user-input-and-displaying-a-prompt-code-in-c-language-nio</link>
      <guid>https://dev.to/drazen911/reading-user-input-and-displaying-a-prompt-code-in-c-language-nio</guid>
      <description>&lt;p&gt;Here's an example code in C language for reading user input and displaying a prompt:&lt;/p&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;p&gt;int main() {&lt;br&gt;
    char input[100];&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(1) {
    printf("Enter a command: ");
    fgets(input, 100, stdin);

    printf("You entered: %s", input);
}

return 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;In this code, we first declare a character array input with a size of 100, which we will use to store the user's input. We then use a while loop to continuously prompt the user for input and display the input back to the user.&lt;/p&gt;

&lt;p&gt;Within the loop, we use the printf function to display the prompt "Enter a command: " to the user. We then use the fgets function to read the user's input from the standard input stream stdin and store it in the input array. The fgets function takes three arguments: the array to store the input, the maximum number of characters to read, and the input stream to read from.&lt;/p&gt;

&lt;p&gt;Finally, we use the printf function again to display the input back to the user with the message "You entered: ". The loop will continue to run indefinitely until the program is terminated.&lt;/p&gt;

&lt;p&gt;👉Note that this is a basic example and does not handle input validation or errors. In practice, it's important to validate user input to avoid buffer overflow or other security vulnerabilities.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>career</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is shell 0x00 basic project?</title>
      <dc:creator>Olalekan Omotayo</dc:creator>
      <pubDate>Fri, 31 Mar 2023 15:51:44 +0000</pubDate>
      <link>https://dev.to/drazen911/what-is-shell-0x00-basic-project-4706</link>
      <guid>https://dev.to/drazen911/what-is-shell-0x00-basic-project-4706</guid>
      <description>&lt;p&gt;The "Shell 0x00" project, also known as the "Simple Shell" project, is a programming project commonly assigned in computer science courses and bootcamps that focuses on creating a simple Unix shell program in the C programming language.&lt;/p&gt;

&lt;p&gt;A Unix shell is a command-line interface that allows users to interact with the operating system by executing commands and programs. The "Shell 0x00" project typically requires students to write a C program that can read input commands from the user, parse the input, and execute the corresponding programs or commands.&lt;/p&gt;

&lt;p&gt;The "Shell 0x00" project is typically divided into several stages or milestones, each of which adds more functionality to the shell program. Some of the basic features that may be included in the initial stages of the project include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading user input and displaying a prompt&lt;/li&gt;
&lt;li&gt;Parsing user input to separate commands and arguments&lt;/li&gt;
&lt;li&gt;Executing basic commands such as "cd" and "exit"&lt;/li&gt;
&lt;li&gt;Handling errors and displaying error messages&lt;/li&gt;
&lt;li&gt;More advanced features, such as piping, redirection, and background processes, may be included in later stages of the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, the "Shell 0x00" project is a valuable learning experience for students who want to improve their understanding of Unix systems and low-level programming concepts in C.&lt;br&gt;
Checkout for more details on this topic in my next article 👍&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>devops</category>
    </item>
    <item>
      <title>C Preprocessor Directives.</title>
      <dc:creator>Olalekan Omotayo</dc:creator>
      <pubDate>Fri, 31 Mar 2023 15:07:55 +0000</pubDate>
      <link>https://dev.to/drazen911/c-preprocessor-directives-3be4</link>
      <guid>https://dev.to/drazen911/c-preprocessor-directives-3be4</guid>
      <description>&lt;p&gt;In C language, the preprocessor directives are used to perform certain operations before the code is compiled. These directives begin with a hash symbol (#). Here are some common preprocessor directives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;#include - This directive is used to include the contents of another file in the current file.
Example:
#include &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.#define - This directive is used to define a macro.&lt;br&gt;
Example:&lt;/p&gt;

&lt;h1&gt;
  
  
  define PI 3.14159
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;#ifdef, #ifndef, #else, #endif - These directives are used for conditional compilation.
Example:
#ifndef DEBUG
printf("Debugging is off\n");&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  endif
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;#pragma - This directive is used to provide additional instructions to the compiler.
Example:
#pragma pack(push, 1)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's an example of how preprocessor directives can be used in C code:&lt;/p&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;h1&gt;
  
  
  define PI 3.14159
&lt;/h1&gt;

&lt;p&gt;int main() {&lt;br&gt;
    float radius = 5.0;&lt;br&gt;
    float area = PI * radius * radius;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;printf("The area of the circle is: %f", area);

#ifdef DEBUG
    printf("\nDebugging information:\n");
    printf("The radius is: %f\n", radius);
    printf("The area is: %f\n", area);
#endif

return 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;In this example, we have used the #include directive to include the standard input-output header file. We have also defined a macro PI using the #define directive. Finally, we have used the #ifdef directive to conditionally compile some debugging statements.&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>career</category>
      <category>c</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
