The great grandson of Husnu Sensoy

January 13, 2007

STRTOK for C guys…

Filed under: C — kocakahin @ 1:01 am

Introduction 

Thanks for your question Ahmet. String tokenizer is one of the most strange functions of C string library. First let me talk about tokenization concept. Assume you are given a string and another fixed delimiter string. Say your string is             “The great grandson of Husnu Sensoy” and the delimiter is happy space character ” “. A token is defined to be any minimum charactered string of the given string between either two delimeter (” “) string or between a delimeter string and string start/end. So the tokens for our example are:

The

great

grandson

of

Husnu

Sensoy

Next question is that how to do this in C ? Here is it:

#include <stdio.h>
#include <string.h> /*Required for strtok function*/

int main() {

    char string[] = “The greatgrandson of Husnu Sensoy”;
    char* token;
    const char dlm[] = ” “;
   
    token = strtok(string,dlm);
   
    while( token != NULL) {
           printf(“%s\n”, token);
           token = strtok(NULL,” “);
    }

    return 0;
}

January 11, 2007

How do you feel about C Strings?

Filed under: C — kocakahin @ 5:00 pm

Hi dear,

As you know we don’t talk much about  strings in Cmpe 150. Do you need help about them? Please leave comments…

January 4, 2007

C is first for sure…

Filed under: C — kocakahin @ 3:05 am

Remember that I’ve started my Blog one week ago. And here is my first write-up on  a topic mixing up minds in C.

Article:

http://husnusensoy.files.wordpress.com/2007/01/c-memory-allocation.pdf

Source:

http://husnusensoy.files.wordpress.com/2007/01/memallocation.doc (Convert extension to .c)

Blog at WordPress.com.