We discuss here some common mistakes which we do during programming.Here are the same list of these type of mistakes:-
(1)When we passing a pointer to a function which is a pointer for array then there is no need to do malloc again then we allocate a new memory which is pointed by that poniter.Example:-
int* f1(int* );
void main()
{
int valueforb = 10;
int *bb = (int*)malloc(size*sizeof(int));
for(long unsigned int iterator = 0 ;iterator < size;iterator++)
{
bb[iterator]= valueforb ;
valueforb+=2;
}
f1(bb);
_getch();
}
int* f1(int* b)
{
*b = (int*)malloc(size*sizeof(int));
for(long unsigned int iterator = 0; iterator < size ; iterator++)
{
printf("%d ",b[iterator]);
}
return b;
}
(2)Compatibility of various datatypes and modifiers:-If we don't know which modifier used with which datatype it causes a big trouble.So we can understand it by these link:
http://amarsinghbishen007.blogspot.in/2013/03/compatibility-of-various-data-types-and.html
(3)Unusual behaviour of signed and unsigned modifier with float:-Here is a link which describe us about this problem:-
http://amarsinghbishen007.blogspot.in/2013/03/unusual-behaviour-of-signed-and.html
(4)Right Shift of signed,unsigned char & int:-Here is a link which describe us about this problem:-
http://amarsinghbishen007.blogspot.in/2013/02/right-shift-of-signedunsigned-char-int.html
(5)using shift operator:-Here is a link which describe us about this problem:-http://amarsinghbishen007.blogspot.in/2013/01/shift-operator-signedunsigned.html
(6)We need to be very careful in giving a path for the file because if we left a \ (slash ) only then it does not give an error .We are unable to understand which type of error occurred .
(1)When we passing a pointer to a function which is a pointer for array then there is no need to do malloc again then we allocate a new memory which is pointed by that poniter.Example:-
int* f1(int* );
void main()
{
int valueforb = 10;
int *bb = (int*)malloc(size*sizeof(int));
for(long unsigned int iterator = 0 ;iterator < size;iterator++)
{
bb[iterator]= valueforb ;
valueforb+=2;
}
f1(bb);
_getch();
}
int* f1(int* b)
{
*b = (int*)malloc(size*sizeof(int));
for(long unsigned int iterator = 0; iterator < size ; iterator++)
{
printf("%d ",b[iterator]);
}
return b;
}
(2)Compatibility of various datatypes and modifiers:-If we don't know which modifier used with which datatype it causes a big trouble.So we can understand it by these link:
http://amarsinghbishen007.blogspot.in/2013/03/compatibility-of-various-data-types-and.html
(3)Unusual behaviour of signed and unsigned modifier with float:-Here is a link which describe us about this problem:-
http://amarsinghbishen007.blogspot.in/2013/03/unusual-behaviour-of-signed-and.html
(4)Right Shift of signed,unsigned char & int:-Here is a link which describe us about this problem:-
http://amarsinghbishen007.blogspot.in/2013/02/right-shift-of-signedunsigned-char-int.html
(5)using shift operator:-Here is a link which describe us about this problem:-http://amarsinghbishen007.blogspot.in/2013/01/shift-operator-signedunsigned.html
No comments:
Post a Comment