Browsing all articles by jigar patel
Apr
27

Difference between c and c++ and java programming languages

Author JIGAR PATEL    Category c++, tips     Tags

In last 2 yeas i have worked a lot on C Programming But now days i need to work on C++ and Java programming language. I have not time to take book of C++ or java programming and start to read that…In any programming language most of the stuff are common. So you know one language very well then by keeping that in mind you can learn other language very well.

Some days ago i found this article and it helped me a lot. i  hope this will also help you….

C++ Style Languages: C++, Objective C, Java, C#

  • it shows the hello world program , version checks,used libraries,
  • primitive  data types,
  • arithmetic and logical operation
  • arrays and strings,
  • regular expressions,
  • dates and time,
  • functions declaration ,
  • execution control flow,
  • files operatins,
  • processes and environment,
  • libraries and namespaces
  • concept of objects

read more

Apr
20

Little endian and Big endian in C programming

This is the most complex concept…. i have read enough on net and some books but   still i was not getting this concept. i was not understanding how this will effect my c code. But i have did some  experiments with some example code and tried to understand things. and here now i am going to share those examples.

In computing, the term endian or endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item as stored in external memory (or, sometimes, as sent on a serial connection)

You can understand basic things about at 

Little endian and Big endian

Big-endian

Mar
5

How to access/unblock songs.pk in india?

 

                        Due to the pirated supply of music kolkata high court have banned songs.pk and now it can’t be accessed in india.

All isp’s have been asked to put an injection so that songs.pk can’t be accessed.
Following are several Indian ISP names included which have to block Songs.pk in India.

 

 

Sify Technologies Ltd
Dishnet Wireless Ltd
Wipro Ltd
Hathway Cable & Datacom Pvt Ltd
Tata Teleservices (Maharashtra) Ltd
Hughes Communications Ltd India
Reliance Communications Infrastructure Ltd
Reliance Wimax Ltd
Bharti Airtel Ltd
Vodafone India Ltd
BG Broadband India Pvt Ltd

 Now to access such blocked sites you need proxy to these blocked sites.

read more

Feb
27

C programming interview questions and answers for freshers

i have seen that in c programming based  interview most of the question are based on some concept clear question and answer.

i have been posting that all tips on this ShareProgrammingTips but here i am just going to List down some good question on C programming.

1>

How will you set, clear ,toggle and check a single bit in C?

2>

Do you know the Concept of Octal literal in C

3>

Do you know the difference between all standard version of c language

4>

How will you detect memory leakage in C program?

5>

Do you know about Implementation limitation of c programming language

read more

Feb
26

What’s the need of using encapsulation { do..while(0) block } in define a macro in C programming?

While reading many codes in c programming based open source project i came to know one interesting things. Let me explain you by some sample code.

#define Assert(v)   if(!(v)) printf("Error occurred at: %s, in %s at %i",  #v, __FILE__, __LINE__);

At most of the experienced people used to write such macro in following style

 #define Assert(v)   do { if(!(v)) printf("Error occurred at: %s, in %s at %i",  #v, __FILE__, __LINE__); } while(0)

This method is called as making encapsulating our macro.

Now let me explain you whats the need of this….

read more

Feb
22

Short-circuiting in C Programming Expressions………….!!!

Author JIGAR PATEL    Category c, Tips     Tags

One Superb thing i learn today is  Short-circuiting in C Programming Expressions. 

Let me explain you by code

#include <stdio .h>
int main() {
   int a = 0;
   int b = 1;
   int c = 2;
   int d = 3;
   a = ++b && ++c || ++d;
   printf ("b = %d,  c = %d, d = %d, a = %d", b, c, d, a);
   return 0;
}</stdio>

if you think output of this program will be

b = 2, c = 3, d = 4, a = 1

then you need to read this whole post..!
read more

Feb
19

In embedded domain, Copying of structure is why avoided in c programming?

 

 

Generally  In embedded software domain for copying structure of same type people dont prefer to use direct assignment and do that by memcpy function or by doing assignment of each element of structure.

Look at Example

struct student {
int roll_no;
int age;
};
struct student exmple1 = {32,15};
struct student exmple2;

for copying exmple1 into exmple2.. instead of writing direct

exmple2=exmple1;

people like to use

memcpy(exmple2,exmple1,sizeof(struct student));

or

exmple2.roll_no=exmple1.roll_no;
exmple2.age=exmple1.age;
Why?

read more

Feb
11

How to change the buffering option for any specified stream in c programming?

Author JIGAR PATEL    Category c, Tips     Tags

Many of  us faced this problem. Sometimes we put some debug prints in our code this way

fprintf(logfile,"successfully reached at debug-point 1\n"); 
 
some code is here
 
fprintf(logfile,"successfully reached at debug-point 2"); 
 
Here segmantaion fault occur due to some reason

Now in this condition only debug-point1 will be print on logfile debug-point 2 print was written to buffer to be used for I/O operations with the specified stream logfile.  but its not flushed because it didnt get \n  and not written on logfile and program crash  so we thinks that crash occur after debug-point1

read more

Jan
31

Whether should i use processes or threads in Linux?

While designing any system usually we might confuse between thread and process usage . We think should we use thread or process for our requirement. Which will be the best choice.?

 

So Here are some guidelines to help you……

 

 

  • All threads inside a program always run from the same executable binary. Where a child process , may run a from different executable binary by calling an exec function.
  • If one process crashes or has a buffer overrun, it does not affect any other process at all, whereas if a thread crashes, it takes down all of the other threads in the process because threads share the same virtual memory space and other resources. read more
Jan
30

Convert file descriptor to file pointer | Convert file pointer to file descriptor in Linux by C programming

 If you all ready know the difference between file descriptor and file pointer then good otherwise please read this post

Whats is difference between file descriptor and file pointer?

 

 

File descriptor to file pointer :

for converting file descriptor to file pointer in linux fdopen() function is used

#include <stdio.h
FILE *fdopen(int fildes, const char *mode);

fildes is file descriptor

mode is the character value which indicate the mode of file operation (same as we use in fopen() function)

Example :

#include <stdio .h>
#include <fcntl .h>
 
int main(){
int fd;
FILE *fp;
fd = open("shareprogrammingtips.txt",O_WRONLY | O_CREAT | O_TRUNC);
if(fd<0)
{
   printf("open call fail");
   return -1;
}
 
fp=fdopen(fd,"w");
fprintf(fp,"we got file pointer fp bu using File descriptor fd");
fclose(fp);
close(fd);
return 0;
}
</fcntl></stdio>

read more

Follow us on Twitter! Follow us on Twitter!

Search in this website

our sponsors

latest comments

Find us on Facebook

Top Authors

35 posts
saurabh
22 posts
10 posts

Find us on stackoverflow

Polls

Tell us who you are

View Results

Loading ... Loading ...

My Bookmarks

Sponsers Link