GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  IBM  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 39 of 98    Print  

What will be result of the following program?

void myalloc(char *x, int n)

{

x= (char *)malloc(n*sizeof(char));

memset(x,,n*sizeof(char));

}

main()

{

char *g="String";

myalloc(g,20);

strcpy(g,"Oldstring");

printf("The string is %s",g);

}

a) The string is : String

b) Run time error/Core dump

c) The string is : Oldstring

d) Syntax error during compilation

e) None of these


  
Total Answers and Comments: 1 Last Update: November 23, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 23, 2007 03:42:55   
Zhang Long        

RE: What will be result of the following progra...

the answer B is right cause g is a pointer to a constant string so the function strcpy will fail.


 
Is this answer useful? Yes | No

 Related Questions

Main(){printf("%u",main);}what will be the output?main(){int 1,b;int con;1=b=2;con (b==1) ? 1 : 0;printf("%d",con);} what will be the value of con?

Latest Answer : Normalization is the process of eliminating the redundancy, data replication, and providing the consistancy, which means while we r designing the database we should take care of table design by eliminating the multiple occurances of fields and we should ...


If you type in the commandnohup sort employees > list 2 > error out & and log off ,the next time you log in . the output will bea). in a file called list and the error will de typed in a file error outb). there will be no file called list or error outc). error will be logged in a file called list and o/p will be in error outd). you will not be allowed to log ine). none of the above

It is a data structure that defines all specifications of a file like the file size ,number of lines to a file ,permissions etc.  

The UNIX shell is....a).does not come with the rest of the systemb).forms the interface between the user and the kernelc) does not give any scope for programmingd) does not allow calling one program from with in anothere) all of the above
b  

Result of the following program ismain(){int i=0;for(i=0;i<20;i++){switch(i)case 0:i+=5;case 1:i+=2;case 5:i+=5;default i+=4;break;}printf("%d,",i);}}a)0,5,9,13,17b)5,9,13,17c)12,17,22d)16,21e)syntax error
d  

What is the resultmain(){char c=-64;int i=-32unsigned int u =-16;if(c>i){printf("pass1,");if(c
c  

What will the following program do?void main(){int i;char a[]="String";char *p="New String";char *Temp;Temp=a;a=malloc(strlen(p) + 1);strcpy(a,p); //Line no:9//p = malloc(strlen(Temp) + 1);strcpy(p,Temp);printf("(%s, %s)",a,p);free(p);free(a);} //Line no 15//a) Swap contents of p & a and print:(New string, string)b) Generate compilation error in line number 8c) Generate compilation error in line number 5d) Generate compilation error in line number 7e) Generate compilation
b  

In the following code segment what will be the result of the function, value of x , value of y{unsigned int x=-1;int y;y = ~0;if(x == y)printf("same");elseprintf("not same");}a) same, MAXINT, -1b) not same, MAXINT, -MAXINTc) same , MAXUNIT, -1d) same, MAXUNIT, MAXUNITe) not same, MAXINT, MAXUNIT
a  


 Sponsored Links

 
Related Articles

Linux Thin Client Networks Design and Deployment Review

Linux Thin Client Networks Design and Deployment Review Introduction This book is written by David Richards a veteran Linux thin client network designer Designed for System Administrators Linux Thin Client Networks Design and Deployment goes over the concepts which are related to thin client network
 

ODP.NET - Handling Nulls when Working with OracleDataReader

ODP NET Handling Nulls when Working with OracleDataReader When we work with OracleDataReader or for that matter even with data rows in a data table we may come across nulls The following is the efficient way to deal in with such scenarios mosgoogle geshibot language VB NET&quot; create connect
 

ODP.NET - Handling Nulls when Executing with ExecuteScalar

ODP NET Handling Nulls when Executing with ExecuteScalar The most important issue to remember is that ExecuteScalar simply returns an object type of data The object refers to any data type within NET If the data type of your variable matches with the type of object returned by ExecuteScalar an impli
 

Home Networking

Home Networking Home networks are creating the modern day offices at home for individuals who prefer to stay at home while working For domestic usage the home networks found no uses as most people could afford only one computer However there are families that find one computer is not enough for them
 

Network Topology

Network Topology There are two levels in a network topology and there are five kinds of network topologies The networks can be connected at two levels the physical and the other is logical A topology basically defines how the network has to be designed and provides a structure to the network mosgoog
 

Network Management

Network Management Network management is the method of managing the tools that belong to a network and maintaining administering all the systems that are connected in the network For one to be able to efficiently manage a network that person should be a qualified network administrator and should hav
 

Network Designs

Network Designs While designing a network many factors have to be taken into consideration like the area to be covered capacity of data that has to be handled and even security issues However when it comes to networks there are LANS or the Local Area Networks and WAN the Wide Area Networks These are
 

Online Virtual Business Network

How to begin an Online Virtual Business Network What is Virtual Business Network Business and commerce right from the ancient days depended a lot on the physical representation of the business and the physical identity of the customers and other collaborators Most of the business dealings were done
 

Business Networks and International Business

Business Networks and International Business Internationalizing a Business Network Traditionally only big enterprises and companies had the financial strength to become multi national firms In the present era of information technology small businesses and medium scale businesses have joined together
 

Exploring Business Networking

Exploring Business Networking Introduction to Business Networking With the dawn of globalization and international business opportunities Business Networking is the latest buzz word among the business communities The Business Networking relies on the principle of sharing expertise knowledge skills s
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape