January 2014 | C Programming and Computer Geeks

Search MY Blog

Monday, 27 January 2014

Slack Byte and Structure padding in Structures


What is Slack Byte or structure padding in Structure?

CPU/Computer stores structures using the concept of "word boundary".
What is word boundary?
Word boundary is the size of word(bytes) that CPU can process(read/write) at a time. Usually it is the Accumulator size of a processor(CPU). The size of word boundary is machine dependent.

Slack Byte(Padding byte)
In computer with 4 bytes word boundary, the members of structure are stores left aligned on the wordboundary, as shown below. A character data takes one byte and an integer takes 4 bytes. 3 bytes(Padding bytes) between them is left unoccupied. This unoccupied byte is known as the slack byte.

Structure padding
Structure Padding or Slack bytes


Why Padding or slack bytes are required?
Slack byte used for speed optimization. It aligns bytes so that, that can be read/write from structure faster. It is an extra byte, sometimes placed between structure members to align the structure.
Some Platforms like x86, CPU can access data aligned on absolutely any boundary, not only on "word boundary". The mis-aligned access might be less efficient than aligned access. If data is aligned properly, CPU can access the memory(structure members) efficiently and faster.

Note: As far as CPU is concerned, it can access any data on any boundary.

When we declare structure variables, each one of them may contain the slack bytes and the values stored in such slack bytes are undefined(garbage). Due to this, even though the members of two variable values are equal, their structures do not necessarily to be equal. Therefore C does not permit compassion of structures. However, we need to design our own function that can compare the individual members of structure to decide whether the structures are equal or not.

For understanding more, run the below program and check for memory mapping of the structure variable.

#include "stdio.h"
void main()
{
  struct st_demo
   {
char ch;
int i;
   };

  struct st_demo s;

  printf(" Size of int    = %d \n\n Size of char   = %d \n\n Size of struct = %d ",sizeof(s.i), sizeof(s.ch),sizeof(s));
 
  getch();

}

Let assume the size of char is 1 byte and int is 4 bytes(Variable sizes depends on Platforms/Compilers).
According to this, the size of structure variable s should be 5(1+4) bytes.

Slack byte in structures
Output of the demo program
But from the above programs Output, Size of struct is 8 bytes.

So from where we got this extra 3 bytes?
From the memory map we can observe that there are three bytes between variable is unoccupied. These bytes are called slack bytes.

Note: It is not always necessary that a structure variable contains structure padding or slack bytes. 
If anything needs to be added for the above article, Please post it in comment section.


If you liked the above post then don’t forget to share & comment...


Monday, 20 January 2014

Simple Virus Creation in Windows Systems


What is Computer virus?
Nowadays everybody aware of computer virus.
Computer viruses are small software programs that are designed to interfere with computer operation.

Today we will create a small and funny virus, which will reboots the computer.
virus creation with Internet explorer
Computer Virus
Funny Internet explorer virus creation
Whenever we double click on Internet explorer Computer will be restarted. For creating such virus follow the below steps.

1. Go to Desktop

2. Right click > new > Shortcut

3. In “Type the Location of the item” > write: “C:\WINDOWS\system32\shutdown.exe -r -t 00″ without double quotes.

4. Click next and in “Type a name for this shortcut” write ”Internet Explorer” and click Finish.

5. Now Right Click on the shortcut of Internet Explorer and go to “Change Icon” and select the icon of Internet Explorer.


6. Now the virus is ready. Whenever you double click on Internet Explorer Shortcut, Computer will restart.

Note: Same method can be used for any program(like Internet explorer) for creating the virus by changing the name and icon in steps 4 and 5).

Please share, if you likes this post.


Thursday, 16 January 2014

Make your computer Speak


Make your computer speak whatever you input to it.
It looks interesting that, if anybody tells that they will make your computer to speak whatever they write or inputs.
Make your computer speak whatever you input
Make your Computer Speak
To create one such talk script, follow the steps given below:-

Step 1.
 Open Notepad.

Step 2.
 Copy and paste the exact code given below:

     Dim Message, Speak
     Message=InputBox("Enter text and visit http://www.neentech.blogspot.com ","Speak")
     Set Speak=CreateObject("sapi.spvoice")
     Speak.Speak Message


Step 3.
Click on File menu, save As, select All Types in Save as Speak.vbs or "*.vbs"(replace * with your own name.).

Step 4.
Double click on the saved file, then a window will open,like showned in the below figure.
Enter text for computer to speak
Enter text for Computer to speak
Enter some text in enter text column and click OK.

Now your Computer will speak / talk what you typed in step 4.

Windows Compatibility: This VBS file can be executed on all versions of Windows.


Please share it, if you likes the trick.

Tuesday, 14 January 2014

Multiple Sites In a Single Click


How to open multiple sites In a Single Click ???

Hi.. today I will show you some interesting stuff related to opening multiple websites in a single click.

Multiple sites in a single click
Multiple Sites
Do follow these simple steps.

1. Open Notepad.
2. Copy Below Given Code And Paste It In Notepad.

@echo off
start 
www.neentech.blogspot.com
start 
http://www.youtube.com/watch?v=pArdrXM5qLM

3. Now save Notepad As Sites.bat
4. Now open your saved file. It will open three websites in a single click.
5. You can also add more sites by writing Start followed by websites..
Even you can replace the above sites with other websites and play around.


Hope you likes this post. Please share this post with all your friends.

Thursday, 9 January 2014

Hidden secrets of Android phone


Android hidden codes
Nowadays everywhere we can find the Android phones around us. Android is one of the most famous OS for mobiles. We can find lot more useful apps and tools in it. And Along with that we have lot more hidden tools, secrets and information in Android phones.

Here I have listed some of the useful codes.
 
Secret Codes of Android
Android Secrets

1. COMPLETE INFORMATION ABOUT THE PHONE
*#*#4636#*#* 
à [Displays Phone Information, Battery Information, Battery History and Usage Statistics].

2. FACTORY DATA RESET
*#*#7780#*#* 
à [Displays Google account settings, System & application data settings, Downloaded applications, etc...]
Note: This code will not remove current system softwares and applications, and SD card files.

3. FORMATTING ANDROID PHONE or DEVICE
*2767*3855# 
à [It will remove all files and settings including the internal memory storage, and also re-install phone firmware.]
Note: Once you dialed this code, there is no way to cancel this without removing your battery quickly. So think twice before putting this code.

4. UPDATES PHONE CAMERA
*#*#34971539#*#* 
à [ This Updates camera firmware in image, Update camera firmware in SD card, Displays camera firmware version, Get firmware update count ]

5. SERVICE MODE
*#*#197328640#*#* 
à [This code is used to enter into Service Mode, You can run various tests and change settings in the service mode]

6. CREATING BACKUP
*#*#273283*255*663282*#*#* 
à [This code opens a file copy screen where you can back up your media files. Eg: Images, Sounds & Videos]

7. LAUNCH VARIOUS TESTS CODES
*#*#0*#*#*   
à [LCD Test]
*#*#3264#*#* 
à [Version of RAM]
*#*#2663#*#* 
à [Version of Touch Screen]
*#*#0842#*#* 
à [Vibration and Back-light Test]
*#*#2664#*#* 
à [Touch Screen Test]
*#*#0588#*#* 
à [Sensor Test]

8. GET FIRMWARE VERSION INFORMATION
*#*#4986*2650468#*#* 
à [ Phone, H/W, RF Baseband ]
*#*#2222#*#*         
à [ FTA HW-Version ]
*#*#44336#*#*        Ã  [ Phone, CSC, Build Time, Change List Number ]
*#*#1111#*#*         Ã  [  FTA SW Version ]
*#*#1234#*#*         
à [  PDA & Phone ]

9. GPS, WLAN & BLUETOOTH TEST CODES
*#*#232339#*#* [OR] *#*#526#*#* [OR]  *#*#528#*#* ( WI-FI Test )
*#*#232338#*#*  
à [ Display WI-FI Mac Address ]
*#*#1472365#*#* 
à [  GPS Test ]
*#*#232331#*#*  
à [  Bluetooth Test ]
*#*#232337#*#*  
à [  Display Bluetooth Device Address ]



Please share in comment section,if i have missed any codes.

Monday, 6 January 2014

Make Free Phone Calls Online


How to make free phone calls online?
Everybody loves to do free voice calls to their family members and friends, especially when they are in abroad. Here am listing some options for people who are all looking for free phone calls from PC/Laptops.
Free calls to Land lines and Phones
Free Phone Calls

i)      Google Voice Google Voice is the best way to make free calls online, but this is only for US and Canada. Check The Call Rates Here Best Thing About Google Voice is it also helps you to manage the phone numbers you have.

ii)     Call2Friends Call2Friends is also a exciting site to make free calls from PC to Phone. But we can make 2 minutes Call for a day.

iii)   Rebtel 
We have to Register and download one application in order to make the free calls.

iv)     Voip Buster
Voip Buster is one more good application for making free phone calls from PC but they have a time limit of 60 minutes per day.


v)      Vopium 
we need to sign up from your number and then we will receive free 5 minutes talk time to make calls anywhere.

Please update in comments, if you find any other online sites or apps which will provide free phone calls from PC.




Friday, 3 January 2014

HOW TO FIND THE SERIAL KEYS OF DIFFERENT SOFTWARES FROM GOOGLE


A serial number is an alphanumeric identifier for your software that identifies and verifies it as a legal copy, and is often requested during installation or registration.

Follow these below mentioned steps to find the serial keys of a particular software for free.
Software Serial Keys
Serial Key

i)
Go to www.google.com webpage.

ii) Write down the name of the
software which you want to get the key and add 94FBR at the end

Eg:  if you want to find key of IDM then write    "IDM 94FBR" (without quotes)


iii) Search it and you can find many sites with serial keys of those softwares




Hope this post helps you in finding the serial key for your software.

Find More tricks and tips @ Tips & Tricks.

Please comment for any additions or suggestions and Share this post with all your friends.



Wednesday, 1 January 2014

Find out the string length without using strlen() function and any loop.


We are having many methods to find the string length for a given string, like implementing the strlen() functionality using loop, etc..

Here in the below program, we are going to see some interesting logic which can give us the string length..

#include "stdlib.h"
#include "stdio.h"

int main()
{

//string length without using strlen() and loop.
     char str[150] = {0,};
     int length = 0;

     printf("Please enter a string:\n");
     gets(str);

     printf("\n\n");

     length = printf("%s", str);
     printf("\n\nLength of entered String is = %d", length);

     getch();
     return 0;
}

Output:

C Program for String length with out using strlen() function and loop
String length by printf()

Logic: We all know that printf() function returns the number of characters displayed(or printed ) on output screen. So using this logic we have found the string length for the entered string.


Read more about basics of Input/output functions.

Hope this Post recalled your basics once again..

Please share it with all your friends.

Post comments for any clarification and doubts. And also share your ideas/opinions as well.

Search This Blog