Jump to content

Check out our Community Blogs


Member Since 22 Sep 2009
Offline Last Active Aug 04 2018 03:13 PM

#667957 Codecall IRC?

Posted by Guest on 05 February 2014 - 09:11 PM

There have been a few tries at having an irc channel. The channels were active for a little while but inevitably people would lose interest. I think we just don't have enough users on here that are really active.
  • 2

#627070 Hey What's Going On

Posted by Guest on 16 April 2012 - 08:45 AM

One quick question, do you guys allow posting of programming videos in the tutorial section of your forum? Like youtube videos for specific concepts.

Yes. In fact, there's a whole section of the forum called Video Tutorials just for that purpose.
By the way,
Posted Image
  • 1

#626082 What's Up?

Posted by Guest on 09 April 2012 - 01:39 PM

I've been lurking on and off, and not programming much, mostly useful little bash/python scripts for my day to day life. I have this urge to get back into it.
So what have I been up to, in fancy list format?
  • My programming passion pretty much came to a halt when I got an Xbox 360 in early 2010.
  • That fall, I think, I started reading reddit more, and watching videos on Youtube.
  • After that, I spent a lot of time listening to music, mostly getting into progressive rock.
  • I had a hectic first semester of University. One fun thing I did was I built a gaming PC to replace the Xbox, I'll probably start a thread about it in the hardware forum.
  • Now I've had a sort of "experimental" second semester, taking some music classes at a community college. But, I don't think I want to do anything with music. Playing and making music seem pretty boring actually, listening is where it's at.
  • Recently, I started messing with Arch Linux more. I had it installed on my desktop, but Ubuntu was still on my netbook. So I've installed Arch on my netbook, and just for fun, on my Android phone. I've been doing a lot more hackish things with Arch then I did before. This has launched me back into programming. I've bought a couple of new books, because books are usually what inspire me to code. (Sorry internet tutorials, you generally don't cut it.)
It's a good thing that I'm able to get into a productive hobby. :)
Oh, and if you want to hang out, I'm going to be available for chat on the #codecall channel on freenode's IRC. irc://irc.freenode.net/#codecall
So that's basically it. What's up with you guys? How's life been? Have you done anything interesting, computer/programming related or otherwise?
  • 2

#625291 CODECALL migrated to IPBoard 3.3

Posted by Guest on 02 April 2012 - 12:57 PM

A few things I notice right off the bat:
  • Titles like Code Warrior are gone, it would be nice to have those back.
  • Blogs don't work, although it does say "Conversion in process." Hopefully they'll be back soon.
  • I think the original biggrin smiley is gone. :D Amr's version still works though. :amr:
  • I have minor issues with the theme. It's all subjective though. :)
  • Some of the light grey text could stand to be darkened. Contrast makes it easier to read.
  • There are very faint lines between each listed thread or forum. It would be nice if those were darker, too. Makes everything distinct, functional.
I'll amend this post if I notice any other problems.
  • 1

#577927 Happy Birthday CodeCall!

Posted by Guest on 25 October 2010 - 08:46 PM

Five years ago, today, CodeCall was created with the intent to help others, share ideas, and create a community of people who share a common passion for programming. Thanks to you, each year we have grown bigger in both users and content, and closer together as a community. I would personally like to thank the steadfast members who come back day after day and contribute their knowledge, whether minimal or massive, every little bit is appreciated. You are the reason we are still here today, and why we will be here tomorrow.

That's me, quality content provider.

I would also like to give a special thanks to the staff for keeping our forums clean of spam, and mediating conflicts as they arise.

Thanks staff!

If you remember, tell us how you found CodeCall, or what keeps you here today, or what you would like to see in the future.

I found CodeCall through Wikipedia. I joined. I don't know why I'm still here, I guess it's the occasionally interesting stuff that happens. :P I would like to see WingedPanther clones in the future.

In celebration, everyone who replies to this thread will receive +rep!

If you insist... :amr:
  • 1

#567740 Very interesting conversation

Posted by Guest on 03 August 2010 - 10:22 PM

Irrelevant? Galaxies spin round and round. Some planets and starts spin closer to the core some further away. (we are rotation in between the inner part of our galaxy and outer part (I believe God placed us in the only "safe" place for the earth to rotate. See there are great dangers in the outer and inner spaces of galaxies that experience terrible/life preventing things that we, being in the center of the galaxy do not experience) ) *sorry for going off topic so much* anyway.

Obviously stars spin around the center of a galaxy, but galaxies do not rotate around a "core" of the Universe. That's a misconception of yours.
Edit: Missed this one:

Would stars the spin more rapidly then our earth have the effect of them moving away?
I hope I'm being clear...

No. First of all, they don't spin fast enough. The Doppler Effect may be observed on the part of the star that would be moving away in the rotation, causing a moving away effect, but then there's the part that would be moving closer to the Earth because of it's rotation, actually causing the opposite effect. (Of course I'm not a professional on this, so you can ask real scientist just to be sure)

I think I would believe if they showed me... but thats just me.

So you believe magicians can preform real magic?

I believe the miracles in the Bible because there where witnesses. Sure it's a "religious book" and some may say, "how can we trust that" but do you know what it was before it was a "religious book" It was people who wrote down what they saw Jesus do. It became a "religious book" when a bunch of guys (not sure who) got together and put the actual thing we know today as the Bible together. Each book that went into the Bible had to go through certain standards to verify its reliability.

How can you verify a random person's observations of miracles? It doesn't even say in the Bible that the authors had any standards at all. It would seem the people who created the Bible believed everything they were told.

I've heard something like the invisible pink unicorn (Russell's tea pot) and I get what whoever made them up is trying to get across. Why believe in something that you can't see, but at the same time prove wrong because of just that. Right? Well God works in peoples lives everyday, He didn't set the world in motion and leave, He is very personal and loving. He does miracles in people lives today.

As already said, the miracles he preforms are very unreliable. Even the most Christian people have tragedies, no matter how much they pray God won't always help them. I think you are attributing the word "miracles" to common things that happen every day. Instead of giving credit the the smart doctors that saved a family member, you say it was God preforming a miracle. If the doctors do not have the medical technology to save someone, you instead blame yourself for not praying enough.

not really the "star". I mean if this where say a Christian forum and an you visited, you my friend would be the star ;). Anyway, carbon dating is very accurate, but there is a catch. This accuracy starts to fade at the mark of around 30,000 years. Listen to this: On August 10, 1990 an Allosaurus bone that was sent to The University of Arizona to be carbon dated. The people who sent this bone (from a dinosaur thought to be 140,000,000 years old) did not tell them it was a dinosaur bone. The results where 9,890 give or take years and 16,120 give or take 220 years. Picture below V

9,890 +/- 60 years and 16,120 +/- 220 years.

Both of these dates are still after what Creationists believe to be the age of the earth. Then again back when the dinosaur lived there was much less carbon in our atmosphere that there is now. Extra carbon adds years to the date.

First of all, this image link doesn't work, and you don't have any sources. Also, scientists make mistakes all of the time, that's why science is about rigorous re-observation. You can't take one mis-observation and say that the concept is bad.
Anyway, there is other proof that the Universe is old. For example, light travels at a finite speed. If the Universe was really created ~100,000 years ago, we wouldn't be able to observe Andromeda (the galaxy closest to us).

Wouldn't that make people become taller over time? or larger? :P (not like Americas obesity)

I'm not sure if molecules really expand, but if they did, you wouldn't notice it in your lifetime. They're just too small, and your lifetime is just too short.

Ohh and thanks ^^ some stuff in this post (the carbon dating) was from another source. (just letting you know as I don't want to get credit for something I didn't figure out)

I saw that article you linked to. A website called something like "answers in genesis" will tend to be very biased. It even said something to the effect of: "If science doesn't support the Bible, then the science is wrong because God is perfect".

Edit: I can't believe I actually thought you had a 'question everything' mentality. It seems you just want to learn about science in order to refute it. If you really want to be open-minded, you have to learn to question your own Bible as well.
  • 1

#560151 Reading And Writing Files In C

Posted by Guest on 20 June 2010 - 06:19 AM

does it work in c++ the same way?

  • -1

#559768 Bit Fields / Flags Tutorial with Example

Posted by Guest on 18 June 2010 - 02:15 AM

Great job on this.
Posted Image
  • 1

#549212 Is this possible to do ?

Posted by Guest on 27 March 2010 - 10:38 AM

Well, I don't think you want to make a compiler, so the best thing to do is include another compiler with your program. Then your program can generate the code and execute a system command to compile it.
  • 1

#531264 Using Structures

Posted by Guest on 10 December 2009 - 10:16 PM

Structures are a very important and useful part of C programming. They are commonly called structs, because that is how they are named in C. Structs are used to group many variable types under one name.

You define a struct as follows:
struct name {
//variables go here
}; //don't forget this semicolon!

When you define a struct, you are defining your own variable type. You can declare variables with the the struct type as follows:
struct name variable;

It's just like you would declare an int, or any other type of variable.

The variables in a struct are called members, look at this struct definition:
struct intfloat {
int a;
float b;

This is a very simple struct with an integer, a, and a floating point number, b. Let's say you declare the struct like this:
struct intfloat test;

To access a member from the test variable, you must use the dot operator:

This sets the member a as the number 6. You can do the same thing with member b:

This sets b as 1.5 because b is a floating point number.

Typedef is a good way to save a lot of typing. It gives a data type a new name. You can do this with the struct definition:
typedef struct {
int a;
float b;
} intfloat;

When using a typedef, you don't need to use struct for every variable you declare, just do this:
intfloat test;

If you haven't used pointers before, please read this tutorial before moving on.
When you declare structs as pointers, you have to use the arrow operator to access members. Let's assume we already defined intfloat with a typedef, just like above:
intfloat test;
intfloat *pointer;
printf("%d, %f\n", pointer->a, pointer->b);
This code will print out:
5, 4.300000

The arrow operator is what dereferences the pointer members.

Here is an example in C that uses structs to show stock statistics:
#include <stdio.h>

typedef struct {
	char *name;
	float value;
	float change;
} stock;

stock setval(char *name, float value, float change) {
	stock temp;
	return temp;

void printv(stock temp) {
	printf("%s stats:\nStock value is:%f, Stock change is:%f\n", temp.name, temp.value, temp.change);

int main() {
	stock google=setval("GOOG", 591.50, 2.48);
	stock redhat=setval("RHT", 27.66, 0.53);
	return 0;

When using structures, it is usually a good idea to have functions that make it easy to handle them. My setval function sets the statistics, my printv function prints out the stock statistics.

As always, feel free to post suggestions, questions, and positive feedback.
Remember, +rep is appreciated. ;)
  • 3

#528868 Pointers: What, How, and Why

Posted by Guest on 01 December 2009 - 01:41 AM

I hope you like our collaborative tutorial! If you choose to +rep ZekeDragon, make sure you +rep me too!
  • 9

#528489 Reading Command Line Arguments

Posted by Guest on 29 November 2009 - 12:06 PM

Just remember me when you have spread it all around :D
  • 1

#528199 Reading Command Line Arguments

Posted by Guest on 27 November 2009 - 03:43 PM

This is a simple tutorial that will show you how to read command line arguments and how to parse them with getopt.

To read command line arguments, you must declare main in a special way.
Here is how you declare main:
int main(int argc, char **argv)
Their are two variables, argc and argv. argc stands for argument count, so it is how many arguments are passed on the command line. argv is a pointer to a pointer, it is the set of actual arguments. This may seem confusing at first.

About argv:
A string is a pointer to a bunch of characters, right? Well argv is a pointer to a bunch of strings. For example, argv[0] is a pointer to the first argument, stored as a string.

Here is an example program that prints out all of the command line arguments you provide:
#include <stdio.h>

int main(int argc, char **argv)
	int i; //counter
	for (i=0;i<argc;i++)
		printf("%s\n", argv[i]);
	return 0;
Seems easy enough, right? Now that is only half of it. Most programs accept arguments using dashes, for example:
ls -a
In Unix would list the directory, and -a means list all files. To recognize and parse these options, programs use a function called getopt.
In order to use getopt, you must include this line:
#include <unistd.h>
Note: This file is part of the C POSIX library, and will not work on Windows unless compiled with Mingw or Cygwin.

Using getopt:
getopt is almost always used in a loop. When there are no more arguments to parse, getopt will return -1. You use getopt like this:
c=getopt(argc, argv, "abc");
argc and argv are the arguments from main. "abc" is the set of characters that are acceptable arguments. c is simply a character that is the argument returned by getopt.

Arguments that take options:
Some arguments need to take an option. For example, many programs use the argument "-f file" to provide file access. When arguments use options, you must follow the acceptable argument by a colon. For example, "a:bc" will accept arguments a, b, and c, and a will have an extra option. The extra option is stored in *optarg.

Here is an example program that can take two arguments, -a and -x. It will tell you if -a is provided, and if -x is provided. It will also tell you the option that -x is provided with.
#include <unistd.h>
#include <stdio.h>

int main (int argc, char **argv)
	int c;
	while ((c=getopt(argc, argv, "ax:")) != -1) {
			printf("-a was provided\n");
			printf("-x was provided with %s\n", optarg);
	return 0;

There are actually more things you can do with getopt, but I will not cover those things here. Any feedback is welcome. Please post here if you have any questions, or improvements. +rep is appreciated a lot!
  • 10

#521524 Using bc (basic calculator)

Posted by Guest on 03 November 2009 - 09:07 PM

bc is a basic calculator in Linux. Even though it is very simple, it is also very powerful because it allows for arbitrary precision arithmetic.
This tutorial is interactive, you are encouraged to type everything in while reading it!

To start bc, type this into the shell:
Yes, it is that easy. You should receive a message like this:
bc 1.06.94
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
Now you can type in simple calculations. Try some of these:
You output should be like this:
bc does order of operations, just like you would expect.
Everything looks fine, except 2/3 equals 0. Why did this happen?
By default bc does not deal with decimal places. If you want bc to show decimal places, you need to set the scale. Type this into bc:
scale is a variable in bc. When you type that into bc, you make scale equal to ten. Now type this:
bc should output 10, because that is what scale equals now. Try this:
Now you should get this as an output:
bc calculated 2/3 correctly to ten decimal places.
Now type this in:
bc should output the square root of 2 on your computer:
sqrt() is a function in bc.
Now quit bc as follows:
Now we will execute bc again, but with two flags.
bc -q -l
The -q makes bc quiet, so you should get no welcome message.
The -l starts bc with a math library, which gives you extra functions to work with. Try this again:
bc should now compute the square root of 2 to 20 decimal places:
When you start bc with -l it automatically sets the scale to 20.
bc also has a few new functions. Try this:
bc just calculated Euler's Number to the first power.
Type this in:
bc calculates the sine of 45 in radians.
To calculate cosine use c(), and to calculate arctangent use a()

Now you should know how to use bc for some everyday calculations. What do we do now? If you have programming experience, programming in bc should be very easy. If you don't program, you don't need to read this section.
While loops are like this:
while (condition) {
Conditions are just like in other programming languages
>, <, <=, >=, ==, !=, etc. will all work in bc
If conditions are like this:
if (condition) {
} else {
For a programmer, this should be straightforward and easy to use.
To print things in bc use the print command
print 1+1
prints 2 to the screen
print "Hello, CodeCall!\n"
Will print Hello, CodeCall! to the screen followed by a newline.
To read a number use the read() function:
Defining a function is like this:
define plusone(x) {
return x
This function will take x as a number and add one to it.
If you want to run a program in bc, the command looks like this:
bc program.bc

That's it! Feel free to post any questions, suggestions or comments. +rep is always appreciated.
  • 4

#521520 Reading And Writing Files In C

Posted by Guest on 03 November 2009 - 07:57 PM

This tutorial will show you how to read and write files in C.
All file functions need <stdio.h> to work properly.

The first thing you need to know about is file pointers. File pointers are like any other pointer, but they point to a file. (Kind of obvious). You define a file pointer as follows:

FILE *filepointer;

In order to make the file pointer point to a file you use the fopen function. The function works as follows:
filepointer=fopen("filename", "mode");

fopen returns a file pointer. It returns NULL if the file does not exist.
fopen takes the first argument as the filename to open. It needs to be a string.
The second argument is the mode argument
Mode specifies what you want to do with the file.
Some modes are:

  • "r" - read the file
  • "w" - write the file
  • "a" - append to the file
  • "r+" - read and write to the file
  • "w+" - read and write, overwrite the file
  • "a+" - read and write, append

These modes will open files in text mode. Files opened in text mode have some bytes filtered out. If you want to open binary files use binary mode by adding a "b" to the mode. For example:

  • "rb" - read the file in binary mode

Dynamic Arrays: Using malloc() and realloc()


There are three input and output streams that are automatically open whenever your program starts. These are stdin, stdout and stderr.
These file pointers work as follows:

  • stdin: opened in read ("r") mode, this file pointer reads from standard input. Any input that you provide on the command line is read by stdin.
  • stdout: opened in write ("w") mode, this file pointer writes to the standard output. Anything written to this stream is printed on the command line.
  • stderr: opened in write ("w") mode, this file pointer writes to the standard error. This is generally meant for error messages that are produced by your program. Whatever is written to this stream is usually printed on the command line like stdout. In most operating systems, there are ways to tell whether output was sent to stdout or stderr.

To read a character from a file, you use fgetc. It is like getchar, but for any file, not just stdin.
It works like this:


fgetc returns the character that is read from the file as an integer.
fgetc takes the file pointer as its only input.
It will automatically increment the pointer to read the next character.

fputc allows you to write a character to a file:
fputc(character, filepointer);

fputc takes an unsigned char as the first argument and the file pointer as the second argument.
fputc returns EOF when it reaches the end of file. EOF is a constant defined in <stdio.h>


Difference between c and c++

You can also use fprintf and fscanf. They work like printf and scanf, except the file pointer is the first argument. They work like this:


fprintf(filepointer, "Hello, World!\n"); //write hello world to the file
fscanf(filepointer, "%d", integer); //read an integer from the file

In order to close the file again, you must use fclose. It looks like this:

fclose closes the file that filepointer points to.

For example, if you want to print the contents of data.txt the code could look something like this:
#include <stdio.h>

int main()
FILE *filepointer;
int character;
filepointer=fopen("data.txt", "r"); /* filepointer points to data.txt */
if (filepointer==NULL) { /* error opening file returns NULL */
printf("Could not open data.txt!\n"); /* error message */
return 1; /* exit with failure */
/* while character is not end of file */
while ((character=fgetc(filepointer)) != EOF) {
putchar(character); /* print the character */
fclose(filepointer); /* close the file */
return 0; /* success */


Getter and Setter Methods

There are also fputs and fgets. fputs is simple, similar to puts. Unlike puts, it does not automatically append a newline to supplied string. It writes a line to a file like so:

fputs("string\n", filepointer);

fgets is a special function in C. It is regarded as the best function in standard C to reliably accept input. Functions like scanf have undefined behavior when given erroneous input. Programs that use scanf or gets can have buffer overflows and be susceptible to exploits! scanf can be nice for those just starting to learn C, but it should never be used in real-world code.
fgets usage looks like this:
char input[100];
fgets(input, sizeof(input), filepointer);

The middle argument is the beauty of fgets. It is the limit of characters that fgets will store in the char array. Usually sizeof(firstargument) is a good idea, unless you are allocating memory with malloc or a similar function.
fgets reads as much as it can. If the input goes over the limit, it will stop. The next file-reading function will continue where fgets left off. (Many times, fgets again, in a loop)
fgets does not discriminate. It reads spaces and newlines with the rest of the input.
fgets returns NULL when nothing can be read. (end of file)
Here's an example very similar to the one above, but instead of fgetc, it uses fgets and fputs:
#include <stdio.h>

int main()
FILE *filepointer;
char string[100];
filepointer=fopen("data.txt", "r"); /* filepointer points to data.txt */
if (filepointer==NULL) { /* error opening file returns NULL */
printf("Could not open data.txt!\n"); /* error message */
return 1; /* exit with failure */
/* while we're not at end of file */
while (fgets(string, sizeof(string), filepointer) != NULL) {
fputs(string); /* print the string */
fclose(filepointer); /* close the file */
return 0; /* success */

That's it! If you have questions, comments or suggestions feel free to post! +rep is very appreciated.


Looking for more beginner tutorials in C?

A simple TCP server using Linux C API

Basic C, for beginners!

Switch and cases in C

  • 4

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download