vicky123
BAN USER- 0of 0 votes
AnswersWhats wrong in this code?
- vicky123 in India
#include<stdio.h>
#include<stdlib.h>
void mystrcpy( char *string2 ,char *string1 )
{
string2 = malloc(20);
while( *string1 != '\0')
{
*string2++= *string1++;
}
}
int main()
{
printf("****************program starts*************************");
char *str1 ="hello world";
char *str2 =NULL;
mystrcpy( str2,str1);
printf("string1 = %s string2 =%s ",str1,str2) ;
getche();
return 0;
}
why str2 will print NULL here| Report Duplicate | Flag | PURGE
Analyst C - 0of 0 votes
AnswersFind the merge point of two linked list.
- vicky123 in India| Report Duplicate | Flag | PURGE
HCL Software Engineer / Developer - 0of 0 votes
Answers3)Reverse individual words of a sentence.
- vicky123 in India| Report Duplicate | Flag | PURGE
HCL Software Engineer / Developer - 0of 0 votes
AnswersReverse an integer without using temp variable.
- vicky123 in India| Report Duplicate | Flag | PURGE
HCL Software Engineer / Developer - 0of 0 votes
AnswersHow to swap two bits in an integer.
- vicky123 in United States| Report Duplicate | Flag | PURGE
HCL Software Engineer / Developer
#include<stdio.h>
#include<stdlib.h>
int main()
{
int * ptr;
int x;
printf ( "sizeof ptr =%d size of int =%d ",sizeof(ptr) ,sizeof(int));
return 0;
}
on compilation:
In function ‘main’:
11:1: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat]
11:1: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]
./a.out
sizeof ptr =8 size of int =4
I am working on Ubuntu Release:12.04
- vicky123 May 16, 2013