struct and typedef of C programming lanugage

C is really powerful system programming language. I believe most of experienced hacker,penetration tester,exploit developer has knowledge of C Language(At least basic). I am not professional or regular experienced programmer. I do coding when i feel of shortness :). Coding is really fun if we can compile without any error... no? I was been keeping forgetting the C structure syntax, The struct and typedef. So i quickly wrote this blog post with the complete code in case it is useful for someone :) . Just see the C comments for explanation of each line.  




#include <stdio.h>

int main()
{

struct pusheax /* struct is collection of variable. Declaring the name of the struct
                        which working like defining TYPE which is also called tag. So here
                        tag is "pusheax". we can call it "Name of struct" */

{
int number; //Variable under parent variable.
int number1; // Declaring another variable.
};



struct pusheax hacker; /* Here "hacker" is instance of "garbage" tag.
                    We must need it for calling variable properly. */



hacker.number=1337; /* now the value of the variable can be set like
                    "hacker.number". */
hacker.number1=31337;


//Same as normal printf function. But here we must need to add dot struct instance otherwise won't work:
printf("hacker.number is : %d\n",hacker.number);
printf("hacker.number1 is: %d\n",hacker.number1); //Same as previous.




struct ini //Another struct.

{
char *str; //It is going to be string pointer, Because the value won't be only "H" :).
int number; //Another variable.
};



struct ini string={0,0}; // We can also initialize the variable!



string.str="Hackers"; //The value of declared varible above under the struct "ini"
string.number=1337; //Another C variable




printf("Char is = %s & number is = %d\n",string.str,string.number); /* Notice that we can delar
                        same variable without any class or function */

//Let use typedef keyword too.



typedef struct puSheax // new? It is structure definition. PuSeax is the name[tag].
//We can use it same as above structure

{
char *know; //C char variable
int knowing; // Another C Integer variable

}p00seax; // The alias name. This is what we are using typedef for.



p00seax p0sheax; //How fun? Now we declared another variable using the alias . Mask?
p0sheax.know="Knowledge is power!"; /*again we need to set the value. So it is completely related
                        with puSheax struct */

p0sheax.knowing=301337; // Same as above



printf("Value of \"know\": \"%s\" and value of \"knowing\" is : \"%d\"\n",
p0sheax.know,p0sheax.knowing); // Perhaps nothing to explain here.


printf("\n\n\n\t\tpusheax.com is for independent ethical hacking,\
        penetration testing,programming practice!!! :)\n\n\n\t"); 
    puts(" Next: http://www.pusheax.com/2013/03/structtypedefarray-and-pointer-all.html\n");
 return 0;        //No error , just exit normally!

//compile: gcc struc.c -o struc
//run: ./struc
}



push@pusheax:~/code$ gcc struc.c -o struc;./struc
hacker.number is : 1337
hacker.number1 is: 31337
Char is = Hackers & number is = 1337
Value of "know": "Knowledge is power!" and value of "knowing" is : "301337"



pusheax.com is for independent ethical hacking,penetration testing,programming practice!!!:)
Next: http://www.pusheax.com/2013/03/structtypedefarray-and-pointer-all.html 


 simple?


If you have any questions please let's discuss :).