Menu
CoddyTech
Course

Kotlin for C Developers

Transfer C experience to Kotlin through null safety, collections, functions, properties and object contracts. Compare pointers, callbacks and copying, then build an order processor and port a stock ledger.

C and Kotlin side by side

The same program in C and in Kotlin, from the lessons of this course.

  1. Strings and Templates

    C printf interprets conversion specifiers and requires arguments of the matching types. Kotlin interpolates values directly into string templates, while println adds a newline. Kotlin String is not a writable null-terminated byte buffer. Top-level functions…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdbool.h>5#include <stdarg.h>6#include <errno.h>7#include <limits.h>8#include <ctype.h>9
    10
    11int main(void) {12const char *name="Ada"; printf("Hi %s!\n",name);13    return 0;14}
    Kotlin
    1
    2fun main(){3val ready=34println("Ready: $ready")5}
  2. Equality and Identity

    C pointer equality compares addresses and strcmp compares null-terminated string contents. Kotlin == delegates to null-safe value equality through equals, while === tests reference identity. Strings compare by content, but ordinary classes do not…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdbool.h>5#include <stdarg.h>6#include <errno.h>7#include <limits.h>8#include <ctype.h>9
    10
    11int main(void) {12char a[]="ab",b[]="ab"; const char *left=a,*right=b; printf("%s %s\n",strcmp(a,b)==0 ? "true":"false",left==right ? "true":"false");13    return 0;14}
    Kotlin
    1
    2fun main(){3val a=String(charArrayOf('t','e','a'))4val b=String(charArrayOf('t','e','a'))5println(a==b)6}
  3. Arrays and IntArray

    C pointer parameters do not retain an array’s element count, and accesses require manual bounds discipline. Kotlin arrays have a checked fixed size, with IntArray providing primitive integer storage on the JVM. Array<Int> has a different representation. size…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdbool.h>5#include <stdarg.h>6#include <errno.h>7#include <limits.h>8#include <ctype.h>9
    10
    11int main(void) {12int values[3]={2,4,6}; printf("%zu\n",sizeof values/sizeof values[0]);13    return 0;14}
    Kotlin
    1
    2fun main(){3val a=intArrayOf(4,8,12)4println(a.last())5}
  4. While, Break, and Continue

    C and Kotlin provide while, break and continue, but Kotlin conditions must be Boolean. A skipped iteration must still make progress when you maintain an index manually. Kotlin string == checks content, so a stop marker can be compared directly instead of…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdbool.h>5#include <stdarg.h>6#include <errno.h>7#include <limits.h>8#include <ctype.h>9
    10
    11int main(void) {12int n=3; while(n>1) --n; printf("%d\n",n);13    return 0;14}
    Kotlin
    1
    2fun main(){3val kept=mutableListOf<String>()4for(word in listOf("tea","","STOP","coffee")){if(word=="STOP")break;if(word.isEmpty())continue;kept.add(word)}5println(kept.joinToString(","))6}
  5. Top-level Functions

    C and Kotlin both allow functions outside classes, but C static at file scope controls linkage rather than creating a Kotlin singleton. Kotlin parameters are read-only bindings. Expression bodies may infer their return type, while a block-bodied non-Unit…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdbool.h>5#include <stdarg.h>6#include <errno.h>7#include <limits.h>8#include <ctype.h>9
    10static int hours(int total) { return total/60; }11int main(void) {12printf("%d\n",hours(125));13    return 0;14}
    Kotlin
    1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}
  6. Input and String Formatting

    C fgets, token readers and strtol have explicit buffer and parsing conventions. Kotlin readlnOrNull represents end-of-input as null, while toInt requires a complete valid integer string. Trim only when permitted and format returned output exactly. The…

    C
    1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <stdbool.h>5#include <stdarg.h>6#include <errno.h>7#include <limits.h>8#include <ctype.h>9
    10
    11int main(void) {12int cents=305; printf("tea: %d.%02d\n",cents/100,cents%100);13    return 0;14}
    Kotlin
    1
    2fun main(){3println("  tea  ".trim().uppercase(java.util.Locale.ROOT))4}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Challenges

2 lessons

More courses for C developers

Learn Kotlin from another language

Frequently asked questions

Who is Kotlin for C Developers for?

For people who already write C and want to learn Kotlin. Each lesson starts from C you know and shows how Kotlin does the same thing, so you skip the beginner basics.

Do I need to know Kotlin already?

No. The course starts with your first Kotlin program. You need C basics: variables, conditions, loops, functions and collections.

How many lessons does Kotlin for C Developers have?

Kotlin for C Developers contains 48 interactive lessons you can complete at your own pace.

What does Kotlin for C Developers cover?

The course is organized into chapters covering: Starting Kotlin, Values and Decisions, Collections and Ownership, Iteration and Transformations, and more.

Is Kotlin for C Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Kotlin for C Developers for free

Get started