• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:09
CET 17:09
KST 01:09
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Rongyi Cup S3 - RO16 Preview3herO wins SC2 All-Star Invitational10SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)19Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
StarCraft 2 not at the Esports World Cup 2026 Oliveira Would Have Returned If EWC Continued Rongyi Cup S3 - RO16 Preview herO wins SC2 All-Star Invitational PhD study /w SC2 - help with a survey!
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
Gypsy to Korea [ASL21] Potential Map Candidates Which foreign pros are considered the best? BW General Discussion BW AKA finder tool
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] Non-Korean Championship - Starts Jan 10 Azhi's Colosseum - Season 2
Strategy
Current Meta Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026!
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread NASA and the Private Sector Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Navigating the Risks and Rew…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1623 users

Beginning Programming

Blogs > ChristianS
Post a Reply
ChristianS
Profile Blog Joined March 2011
United States3278 Posts
November 22 2012 10:11 GMT
#1
So I recently started programming in the C language. Specifically, I've been taking the CSE 5A class at UCSD (although my major is not, and as far as I know, will never be computer science). The good news: programming is incredible and I'm certain I want to pursue it further. The bad news: this class moves incredibly slowly, and I've pretty much decided to forget about where we are in the class and start learning further on my own.


Humble Beginnings
[image loading]
"I taught myself how to play the guitar, which was a bad decision, cause I didn't know how to play it.
So I was a shitty teacher. I would never have went to me." -Mitch Hedberg



My first impression of the programming world is that it's far bigger than I probably have time to explore — which doesn't mean I'm not going to try. The biggest problem is that I'm not totally certain what I actually want to do with any programming skills I might develop; my current major is a biochemistry/chemistry B.S. (although I'm only second year, so I haven't started on the upper division classes), so I don't really know how this would wind up applying. I just know that I'm interested in it, and that computer skills are the sort of thing that will generally come in handy somewhere, even if I don't have a plan for them now.


[image loading]
I know in my head that it would be impossible to explore it all, but my heart won't be satisfied until I've experienced every inch.


I'm programming on a Mac, so I build my programs in TextWrangler and run them in Terminal. I have Xcode and a few other tools downloaded for building larger projects, but since everything I'm doing now can largely fit in a single source file comfortably, I haven't started exploring those programs just yet. I don't really have any graphical tools at my disposal yet, but I wanted to do something other than program algorithms for comparing integers and such. So I built my first project (pictured above).

Right now, the program is just a model of an ascii stick figure on a 64x32 grid. I don't yet know how to output to a separate window where I specify the size, so I just resize Terminal to 64x33 manually (one extra line for input). It accepts w, a, s, d, and x as input. W, a, s, and d move the character around if he isn't at the edge of the game area. X exits the program.

Source code here: + Show Spoiler [Source Code] +
#include <stdio.h>

#define DIMX 64
#define DIMY 32
char display[DIMX][DIMY];


//gVariables
char input;
int end = 0;

struct object
{
      int positionx;
      int positiony;
      int dimensionx;
      int dimensiony;
      char *modelp;
} player;


//Functions
int initializeObjects();
int standardDisplay();
void objectWriter(struct object writee);
int refresh(void);


//Object Models
char playerModel[3][3] =
{
      { 0x20, 0x6F, 0x20 }, /* o */
      { 0x2D, 0x7C, 0x2D }, /* -|- */
      { 0x2F, 0x20, 0x5C } /* / \ */
};


//This function sets the initial value for all objects.
int initializeObjects()
{
      player = (struct object)
      {
            .positionx = 15,
            .positiony = 29,
            .dimensionx = 3,
            .dimensiony = 3,
            .modelp = &playerModel[0][0]
      };
}


//This function displays the grid of characters that is the current screen.
int standardDisplay()
{
      int i, j;
      for (j=0; j<DIMY; j++)
      {
            for (i=0; i<DIMX; i++)
                  putchar(display[i][j]);
            putchar('\n');
      }
}


void objectWriter(struct object writee)
{
      int id = writee.positionx, jd = writee.positiony, im, jm;
      for (jm=0; jm < writee.dimensiony; jd++, jm++)
      {
            for (im = 0, id = writee.positionx; im < writee.dimensionx; id++, im++)
            {
                  display[id][jd] =
                  (*(writee.modelp + writee.dimensionx * jm + im));
            }
      }
}


int refresh(void)
{
      int i, j;
      for (j=0; j<DIMY; j++)
            for (i=0; i<DIMX; i++)
                  display[i][j] = 0x20;
      return 0;
}


int movePlayer()
{
      int movement[2]={0, 0};
      input = getchar();
      switch (input)
      {
            case 'w':
            {
                  if(player.positiony > 1)
                        movement[1] = -1;
                  else
                        printf("/a");
                  break;
            }
            case 'a':
            {
                  if(player.positionx > 1)
                        movement[0] = -1;
                  else
                        printf("/a");
                  break;
            }
            case 's':
            {
                  if (player.positiony + player.dimensiony + 1 < DIMY)
                        movement[1] = 1;
                        else
                              printf("/a");
                  break;
            }
            case 'd':
            {
                  if (player.positionx + player.dimensionx + 1 < DIMX)
                        movement[0] = 1;
                  else
                        printf("/a");
                  break;
            }
            case 'x':
            {
                  end = 1;
                  break;
            }
            default:
                  break;
      }
      player.positionx += movement[0];
      player.positiony += movement[1];
}


int main(void)
{
      initializeObjects();
      while(end != 1)
      {
            refresh();
            objectWriter(player);
            standardDisplay();
            movePlayer();
      }
      return 0;

//So, uh, I should probably start thinking about Steam Greenlight, right?
}


I wrote this program a few weeks ago, so even by now I've learned a few things I would probably do differently. I'll note my own criticisms just to seem slightly less inept when it comes to programming.

+ Show Spoiler [My Own Criticisms] +
-The "switch" decision construct doesn't need to put all the info for cases inside brackets. I dunno why I thought it did.

-I had just learned about global variables in this program and was excited to use them for the first time; I now know many people consider them to be bad form along the same lines as a "goto" command. If I wrote this again I would do it without global variables.

-At least in terminal, this program requires you to hit enter every time you input commands. Not only is this a hassle, but it means that if you enter multiple commands and then hit enter, the program carries out all those commands before waiting for input from you again. This appears to be an inherent characteristic of the getchar() function, so I've been investigating other possible functions to use. Some googling suggests getch() might be a possibility.


But ultimately, I'm looking for feedback from TL. What should I be doing differently? What should I focus on learning? I've read CecilSunkure's stuff on game design, and I think I'll try to buy some of the books he recommended in the near future. In the mean time, does anyone have any tips, tricks, or other manner of advice for me?

"Never attribute to malice that which is adequately explained by stupidity." -Robert J. Hanlon
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
November 22 2012 10:23 GMT
#2
Oh interesting blog! I think this is a great start. Next you could try adding in some walls that the player has to navigate around. After that you could perhaps add in random battles when you walk, the battles can be turn based. I had a lot of fun making my first text turn-based RPG.

Hmm I'd say make sure you're very comfortable using pointers and arrays, and doing string manipulation. These are most important when starting in C I'd say.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
November 22 2012 10:23 GMT
#3
Seems to be that if you're in the research field, you'll probably want to learn Python which seems to be a very popular language for those kinds of calculations. Learning C first is great though, especially since Python is based on C and has mostly similar syntax.

I wouldn't worry too much about what you will use programming for. In modern day society, the computer is a vital tool which most people, at least in developed countries, use every day. Knowing how to program just gives you more power over this universal tool.
ChristianS
Profile Blog Joined March 2011
United States3278 Posts
November 22 2012 10:33 GMT
#4
Oo, very quick feedback. Thanks, guys!

On November 22 2012 19:23 CecilSunkure wrote:
Oh interesting blog! I think this is a great start. Next you could try adding in some walls that the player has to navigate around. After that you could perhaps add in random battles when you walk, the battles can be turn based. I had a lot of fun making my first text turn-based RPG.

Hmm I'd say make sure you're very comfortable using pointers and arrays, and doing string manipulation. These are most important when starting in C I'd say.

In terms of pointers and arrays, I think I've gotten better at those since this program; when I stopped using global variables I had to start passing variables and arrays in functions. I'm not sure whether it's better to pass an array in a function and use array notation or pass a pointer to the array and then use pointer notation, so I've tried to learn both.

In terms of string manipulation, do you have any ideas for programs I should build? I don't know that I have as much practice with string manipulation as I should, but I'm interested in practicing it.

On November 22 2012 19:23 Tobberoth wrote:
Seems to be that if you're in the research field, you'll probably want to learn Python which seems to be a very popular language for those kinds of calculations. Learning C first is great though, especially since Python is based on C and has mostly similar syntax.

I wouldn't worry too much about what you will use programming for. In modern day society, the computer is a vital tool which most people, at least in developed countries, use every day. Knowing how to program just gives you more power over this universal tool.

Are there any advantages to Python other than it's easier to learn and code in? I learned some Python a while back for the fun of it over the summer, but I was under the impression that Python was designed to be a tutorial language — like BASIC, but more useful. I imagine it'd be easy enough to learn Python from a C background, but is there any particular reason I'd want to use Python rather than just using C?
"Never attribute to malice that which is adequately explained by stupidity." -Robert J. Hanlon
Denar
Profile Blog Joined March 2011
France1633 Posts
November 22 2012 10:57 GMT
#5
Very nice to see you enjoying programming and having a lot of fun! It is a very specific mind exercise, that can be very rewarding and make you feel very good for a certain type of people, which you seem to be.

First of all, I wouldn't listen to advices telling you to learn another language, at this point in your discovery, it would only be a syntaxic change which would not allow you to do more stuff right off the bat. Plus, C has always been and still is an excellent language to begin with. Its low-level aspect gives you a very nice understanding of many hardware fundamentals. And it is easier to start with those, than to ignore them and painfully try to catch up later on (as is often seen).

So, some suggestions as to what to do next :

You could try to make your 2d text grid a bit more living, why not develop Conway's Game Of Life on it ? http://en.wikipedia.org/wiki/Conway's_Game_of_Life , a classic.
Then, you will probably want to have some interactivity, from the command line or reading a file at first.

Or you can also look at the open-source community. A lot of amazing projects are available to look at, and learn from, before one day being able to bring your own help to improve them ? Browse through https://github.com/ , there is great educational value, and a lot of creations of different scales by the community.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
November 22 2012 10:57 GMT
#6
On November 22 2012 19:33 ChristianS wrote:
Oo, very quick feedback. Thanks, guys!

Show nested quote +
On November 22 2012 19:23 CecilSunkure wrote:
Oh interesting blog! I think this is a great start. Next you could try adding in some walls that the player has to navigate around. After that you could perhaps add in random battles when you walk, the battles can be turn based. I had a lot of fun making my first text turn-based RPG.

Hmm I'd say make sure you're very comfortable using pointers and arrays, and doing string manipulation. These are most important when starting in C I'd say.

In terms of pointers and arrays, I think I've gotten better at those since this program; when I stopped using global variables I had to start passing variables and arrays in functions. I'm not sure whether it's better to pass an array in a function and use array notation or pass a pointer to the array and then use pointer notation, so I've tried to learn both.

In terms of string manipulation, do you have any ideas for programs I should build? I don't know that I have as much practice with string manipulation as I should, but I'm interested in practicing it.

Show nested quote +
On November 22 2012 19:23 Tobberoth wrote:
Seems to be that if you're in the research field, you'll probably want to learn Python which seems to be a very popular language for those kinds of calculations. Learning C first is great though, especially since Python is based on C and has mostly similar syntax.

I wouldn't worry too much about what you will use programming for. In modern day society, the computer is a vital tool which most people, at least in developed countries, use every day. Knowing how to program just gives you more power over this universal tool.

Are there any advantages to Python other than it's easier to learn and code in? I learned some Python a while back for the fun of it over the summer, but I was under the impression that Python was designed to be a tutorial language — like BASIC, but more useful. I imagine it'd be easy enough to learn Python from a C background, but is there any particular reason I'd want to use Python rather than just using C?

Python just makes you far more productive, you can make far more complex programs far faster than you can with C. Obviously C is much faster, but it's pretty rare with situations where this speed makes a difference. Python is really just designed to be productive and is backed heavily by Google etc. C is more geared towards people who work with embedded devices and operating systems, where you need to work directly with hardware and need very effective performance optimization, while python is geared towards making functional programs quickly.
felisconcolori
Profile Blog Joined October 2011
United States6168 Posts
November 22 2012 12:55 GMT
#7
Truely, if you learn one language well, it is easier to learn additional languages as required. Some have quirks, but the underlying concepts and most of the structure remains the same. (An if... then is always an if...then, even if they use a different notation or format for it.)

Also, programming can be useful in just about any field. A friend of mine used to "do his homework" in astrophysics by gradually expanding a program he wrote to handle all of the various calculations. Which would then perform all of the steps, print them out, and arrive at the answer. I think he also used it in some chemistry related courses, all of his physics courses, and on into orbital mechanics and upper division classes.

(The guy was a freaking genius. Probably still is.)
Yes, I email sponsors... to thank them. Don't post drunk, kids. My king, what has become of you?
Tarot
Profile Joined February 2011
Canada440 Posts
Last Edited: 2012-11-22 15:29:47
November 22 2012 15:17 GMT
#8
Java might be helpful just because it is so widely used in business/enterprise. C is probably a bit too low level for research. You don't really need that level of optimization.

edit: I recall that a lot of bio/chemistry related programming jobs were focused on databases and statistical analysis (using R). I'm not sure if these are the kind of jobs you're interested in. They lean more towards programming than bio/chemistry.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-11-22 19:14:07
November 22 2012 19:13 GMT
#9
On November 22 2012 19:33 ChristianS wrote:
In terms of string manipulation, do you have any ideas for programs I should build? I don't know that I have as much practice with string manipulation as I should, but I'm interested in practicing it.

Sure.
  • Try making a program to concatenate two strings on the heap that are taken from user input.
  • Try reversing a string.
  • Make a program to reverse locations of the words in the strings, but each word isn't reversed.
  • Count the number of words in a string.
  • Make a program to store a staggered array of strings inputted from the user.
  • Make a find and replace program to find all instances of "something" in a string and replace it with "something else". This one might be a bit too hard, so just find and replace a single character should do fine.
Please log in or register to reply.
Live Events Refresh
OSC
11:00
Season 13 World Championship
Classic vs ClemLIVE!
herO vs TBD
WardiTV1503
IndyStarCraft 214
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 214
ProTech137
Livibee 110
JuggernautJason67
Rex 49
StarCraft: Brood War
Calm 3307
Rain 2925
Horang2 1070
GuemChi 515
Shuttle 396
ggaemo 298
BeSt 244
firebathero 238
Snow 152
Hyuk 137
[ Show more ]
Dewaltoss 122
Soulkey 120
Zeus 109
Hyun 73
Backho 51
Mind 38
Movie 36
scan(afreeca) 24
JYJ 17
910 15
Yoon 15
HiyA 10
Free 10
Dota 2
Gorgc4778
qojqva2990
Dendi552
Counter-Strike
fl0m3209
olofmeister2126
Other Games
gofns2775
B2W.Neo1303
Beastyqt651
crisheroes324
RotterdaM300
Mlord266
allub250
Harstem211
Fuzer 163
Hui .142
QueenE120
Mew2King103
DeMusliM89
ArmadaUGS80
ceh958
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Laughngamez YouTube
• Migwel
• sooper7s
StarCraft: Brood War
• FirePhoenix2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 5597
• WagamamaTV852
League of Legends
• Jankos2810
• TFBlade1101
Upcoming Events
RongYI Cup
18h 52m
Clem vs ShoWTimE
Zoun vs Bunny
Big Brain Bouts
1d
Percival vs Gerald
Serral vs MaxPax
RongYI Cup
1d 18h
SHIN vs Creator
Classic vs Percival
OSC
1d 20h
BSL 21
1d 22h
RongYI Cup
2 days
Maru vs Cyan
Solar vs Krystianer
uThermal 2v2 Circuit
2 days
BSL 21
2 days
Wardi Open
3 days
Monday Night Weeklies
4 days
[ Show More ]
OSC
4 days
WardiTV Invitational
4 days
WardiTV Invitational
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-01-20
SC2 All-Star Inv. 2025
NA Kuram Kup

Ongoing

C-Race Season 1
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Rongyi Cup S3
OSC Championship Season 13
Underdog Cup #3
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025

Upcoming

Escore Tournament S1: W5
Acropolis #4 - TS4
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.