C Programming and Computer Geeks

Search MY Blog

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.

Monday, 30 December 2013

Windows 8 OS Keyboard Shortcuts


Windows key – brings up the Metro start screen. You can start typing to search for an app, just like the Win7 start menu.

Windows 8 Keyboard Shortcuts
Windows 8 Shortcuts
Win + D – brings up the old Windows desktop.
Win + C – brings up the Charms menu, where you can search, share, and change settings.
Win + I – opens the Settings panel, where you can change settings for the current app, change volume, wireless networks, shut down, or adjust the brightness.
Win + Z – opens the App Bar for the current Metro application.
Win + H – opens the Metro Share panel.
Win + Q – brings up the Metro App Search screen.
Win + W – brings up the Metro Settings search screen.
Win + F – brings up the Metro File search screen.
Win + K – opens the Devices panel (for connecting to a projector or some other device)
Win + , (comma) – Aero Peek at the desktop.
Win + . (period) – Snaps the current Metro application to one side of the screen. (Right side)
Win + Shift + . (period) – Snaps the current Metro application to the other side of the screen. (Left side)
Win + J – switches focus between snapped Metro applications.
Win + Page Up / Down – moves the current app to the other monitor.
Win + Tab – opens the Metro application switcher menu, switches between applications.
You might notice that we didn’t show screenshots of how all these shortcut keys work, and there’s a reason for that: you need to test them out for yourself to really learn how they work.
Win+X – lunch kind of start menu, very useful
Windows Key + Print Screen saves a screenshot into your Pictures folder. It’s quite handy.

Please share if we missed any other shortcuts..

Tuesday, 24 December 2013

C Language Advantages



Advantages
Ø  C language is a base or building block for many other currently known languages.

Ø  C language has varieties of data types and powerful operators. Due to this, programs written in C language are efficient, fast and easy to understand.


Ø  C is highly portable language. C programs written for one computer can easily run on another computer without any change or by doing a little change.

Ø  There are only 32 keywords in ANSI C and its strength lies in its built in functions. Several standard functions are available for developing programs.


Ø  Another important advantage of C language is its ability to extend itself.
A C program is basically a collection of functions that are supported by the C library this makes us easier to add our own functions to C library. Due to the availability of large number of functions, the programming task becomes simple.

Ø  C Programming is a structured programming language. This makes developers to think of a problem in terms of function modules or blocks. The Collection of these modules makes a complete program or software. This modular structure makes program debugging, testing and maintenance more easier.

C Language Advantages over C++
C vs C++


Disadvantages

Ø  There is no runtime checking in C language.
Ø  There is no strict type checking. For example, we can pass an integer value for the floating or character data type.
Ø  C does not have concept of OOPs, that’s why C++ is developed.
Ø  C does not have the concept of namespace.

Ø  C does not have the concept of constructor or destructor.

Monday, 23 December 2013

What is "void" type in C/C++ ?


Before going to the void data type, First let us understand the data type concept.
In C/C++ programming language, the data types refer to an extensive system used for declaring/defining variables/objects or functions of different types. The type of a variable determines how much memory space it occupies in storage and how the bit pattern stored is interpreted.
char, int, float, double, void etc.. are some of the data types in C language.
Data types in C/C++
Data Types in C/C++

Now coming to the void data type..
void is basically a keyword to use as a placeholder where you would put a data type, to represent "no data".
void actually refers to an object that does not have a value of any type.

When "void" type is used in function definition it means that function will not return any value.

When "void" is used with pointer type variable declaration eg: void* a or void* b etc. It means any empty type i.e. later in the program you can point any data type(int or float type variable) to a or b respectively.


Click here for more C Tutorials and Concepts.

Saturday, 21 December 2013

Difference between Compiler and Interpreter

The main difference between Compiler and Interpreter is:
Compiler translates the program statements(Source Code) into Machine Code in one go i.e. all lines of program simultaneously. That's why all compiler based languages shows all the errors together.

While interpreter translates the source code into machine code one statement at a time. That's why program execution cannot proceed to next statement until the previous error is corrected/rectified.

Find more C Concepts here..

Thursday, 19 December 2013

How to Reveal Hidden Passwords (Asterisks) In Web Browsers



In many situations that we require to know what lies behind those asterisks. In many cases for different website login's we need to enter the passwords which will be hidden form us. Here is the simple trick to reveal the passwords on our web browsers.

Revel Hidden Passwords
PASSWORD
These hidden passwords are disguised with the help of simple HTML and CSS. So just by changing the value of something specific will easily reveal what’s behind those bullets or asterisks.
Here we see how to revel the passwords in Google Chrome and Internet explorer.


Google Chrome browser
In any website which contains your saved password, right click on the password box and click on Inspect element as showed in the below picture.
Reveal hidden Passwords
Hidden Password

Now we can notice the bottom quarter of our screen filled with codes. Now we need to focus on the highlighted part to reveal the password behind the asterisks.
Reveal hidden Passwords
Reveal Password

Now look for type="password" and double click on it. Replace the word “password” with “text”.
It should now look like type="text". And hit Enter.
Reveal hidden Passwords
Password 

That’s it now you can see the text behind the asterisks.
Reveal hidden Passwords
Reveal hidden Password



Microsoft Internet Explorer
In any website which contains your saved password, Go to Tools in the Menu bar and select F12 developer tools from the list as showed in the figure.
Revealing hidden Passwords
Internet Explorer hidden Password

Search for “password” and look for type="password" and double click on it.
Revealing hidden Passwords
Revealing Hidden Password

Replace the word “password” with “text”. It should now look like type="text". And hit Enter.

Revealing hidden Passwords
Hidden Password 

That’s it now you can see the text behind the asterisks in Internet explorer.
Revealing hidden Passwords
Revealing hidden(Asterisks) Password


Click here for more Tips & Tricks

Search This Blog