Skip to content

Commit

Permalink
Update tokenizer.c
Browse files Browse the repository at this point in the history
Signed-off-by: Josef Edwards <joed6834@colorado.edu>
  • Loading branch information
bearycool11 authored Nov 12, 2024
1 parent e5adfaa commit 5c98e59
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tokenizer.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
#ifndef TOKENIZER_H
#define TOKENIZER_H

void tokenize(char *input);

#endif // TOKENIZER_H

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tokenizer.h"

#define MAX_TOKEN_SIZE 100

void tokenize(char *input) {
char *token = strtok(input, " \t\n"); // Delimiters: space, tab, newline
char *token = strtok(input, " \t\n");
while (token != NULL) {
printf("Token: %s\n", token);
token = strtok(NULL, " \t\n");
}
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tokenizer.h"

#define MAX_TOKEN_SIZE 100

int main() {
char input[MAX_TOKEN_SIZE];

// Get input string
printf("Enter a string to tokenize: ");
fgets(input, MAX_TOKEN_SIZE, stdin);

// Remove newline character
input[strcspn(input, "\n")] = '\0';

// Tokenize the input string
tokenize(input);

return 0;
Expand Down

0 comments on commit 5c98e59

Please sign in to comment.