Home Answers Viewqa Development-process Why is this code working

 
 


fabrizio
Why is this code working
0 Answer(s)      a year and 10 months ago
Posted in : Development process

Looking at this piece of code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _point{
  int x;
  int y;
} point;

int main (void)
{

 point *ptr;
 point obj;

 ptr = (point *)malloc(sizeof(char));
 obj.x = 500;
 obj.y = 5000;
 memcpy((void *)ptr, (void *)&obj, sizeof(point));
 printf("point.x = %d, point.y = %d\n", ptr->x, ptr->y);
 return 0;
}

Why is it running correctly when I run it. Shouldn't I get a segfault given I incorrectly do malloc() on sizeof(char) instead of sizeof(point)?

View Answers









Related Pages:
Why this is not working...?
Why this is not working...?  import java.util.*; public class Family { int size_of_family=0; public Person[] members=new Person[size_of_family...); f.printOutFamily(); } }   Post the code of Student.java
Why is this code working
Why is this code working  Looking at this piece of code: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef...\n", ptr->x, ptr->y); return 0; } Why is it running correctly when I
Multi Threading is not working in that why...?
Multi Threading is not working in that why...?   import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Date; public
Code not working
Code not working  i want to write my first applet. I wrote the java program and html code for that. while im running in appletviewer it is asking for security permissions. so, i created a policy file and linked it with html file
Dynamic-update not working in Hibernate.
Dynamic-update not working in Hibernate.  Why is dynamic update not working in hibernate?   Dynamic-update is not working. It means when... am giving you a small block of code for updating of employee detail- public
working of a div tag in html
working of a div tag in html   !DOCTYPE html PUBLIC "-//W3C//DTD...; This is a simple code. but after executing it i am not getting the sentence "content for new Div Tag goes here" in red block. why it is happening like
Your hibernet tutorial is not working - Hibernate
location http://www.roseindia.net/hibernate/firstexample.shtml it working..., Plz specify in detail. you are created three table but why? plz send me code. Thanks
code not working properly
code not working properly  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException...); } } in the above code if i enter a valid username and password i am
why jsp pages are not working on linux but java application is working in windows - JSP-Servlet
why jsp pages are not working on linux but java application is working in windows  java web application jsp pages are not showing the fileds corectly on linux server but same application is working on windows.why
Datagrid not working
Datagrid not working  The code here is working fine, apart from the fact that that I'm using netbeans 6.5 and the servlet v2.5 and struts 1.1.... working. please help me out
Why request.getParameter(
Why request.getParameter(  Hi all, I want to to do upload file in my... uploading file is working but data not store in database because my form field value...="POST"> why it happen? Anybody plz help me.. i want use it my project...plz
UIWebView zoom not working
UIWebView zoom not working  Hi, I don't know why UIWebView zoom not working? Tell the solution. Thanks   Hi, Open the .xib file and set scalesPageToFit to YES. Thanks
calender working in struts - Struts
calender working in struts  when i execute the following code ,that is working properly if i convert to struts html tags that code is not working please help me to rectify the problem
html dropdown not working firefox
html dropdown not working firefox  I am writing a Dropdown code in HTML which is not working in firefox. What could be the reason as it's perfectly working in IE and Crome. Thanks
myJSF,Hibernate and Spring integration code is not working. - Hibernate
myJSF,Hibernate and Spring integration code is not working.  the code given in this url : http://www.roseindia.net/roseindiamembers/login.php i have tried but it does not work. when i write http://localhost
calculate working hour
calculate working hour  why echo not come out? <html><body> <form action="<?php $_SERVER['PHP_SELF'];?>" method="post"> Working hour : <input name="workout" type="text"/><input name="submit1
My Servlet code not working - Development process
My Servlet code not working  HHi, After executing servlet am getting blank screen. Am using weblogic server and Eclipse editor. But jsp is working fine. Steps(what i did ) 1)Created servlet (In eclipse) and export it (saved
why tomcat is shoutdown when access the jsp page - Development process
why tomcat is shoutdown when access the jsp page  I have a menu.when i click on menutitem(jsp page),some time tomcat is shoutdown and sometimes it is working fine  Hi Friend, Please send your code. Thanks
some methods not working on firefox and chrome
some methods not working on firefox and chrome  why some of javascript methods are not working on firefox and chrome? ex : createElement(). Please help me to solve this problem. adv thanx
window.open() not working - Ajax
is that the pop up window is not at all working.. Once I click the button, the page... I went wrong, in the above piece of code.. Regards, Ragavendran.R  
JQuery-event working new element
JQuery-event working new element  I want to know- why not an event(in JQuery) works on my created element through jQuery
why java is securable ?
why java is securable ?  why java is securable ?   Hi... readability as it contains byte code understandable only to JVM. 2)The byte code.... 3) No virus will infect the byte code. Thanks
Ajax not working in jsp
Ajax not working in jsp  I'm using Netbean, Ajax validation in the following code is not working the code succesfully run for first UID validation adn also for ee-mail but does not enter if else for firstname field please help me
JTextfields working with JTextArea
JTextfields working with JTextArea  I have 2 database tables one is history the other is patient, How can I get which every patient is being... on a Jtextarea   hi friend, try the following code below : import java.sql.
ClassPathResource class is not working - Spring
ClassPathResource class is not working  Hi, Below is a sample code... ClassPathResource("hello.xml");BeanFactory factory = new XmlBeanFactory(res); Hello... parsing XML document from class path resource [classpath:hello.xml
why servlet as controller - Struts
why servlet as controller   Hi Friends, Main reasons for using servlet as a controller in struts. why not jsp . Thanks Prakash  Hi... the code that is written in JSP willbe converted finall into Servlet. A single
Why NSString Objective C
Why NSString Objective C  Why we use the NSString class in Objective C and how to define and initialize the NSString Class?   Why NSString..." "This is line 2"; In the last see the code to append
datetimepicker not working in struts2
datetimepicker not working in struts2  Hi, I am using "struts2-dojo-plugin-2.1.6.jar" and the taglib is "<%@taglib prefix="d" uri="/struts-dojo-tags"%>" **sample code:** <%@taglib prefix="s" uri="/struts-tags
camera roll iphone not working
camera roll iphone not working  How to access the camera in my iPhone application. Please explain.   This code explains.., how to roll... UIImagePickerController class. Find the code below.. // Create image picker controller
Sql querry not working
of slabs. CBID is cutblock ID. My code: ResultSet rc=st.executeQuery("select
Why bufferedreader is used in java?
Why bufferedreader is used in java?  Hi, What is the use of BufferedReader class in Java? why bufferedreader is used in java? It will be great if anyone can give me the example code of BufferedReader class in java. Thanks
Working Example for Spring AOP - Spring
Working Example for Spring AOP  Hi All, I need a complete working Java example /Code/Logic for Spring -Aspect Oriented Programming. Code provided will be highly appreciated. -- Deepak Lal
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2...] ^= a[0]; //a[0] ^= a[1]; //this is working correctly. a[0] ^= a[1] ^= a[0] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2...] ^= a[0]; //a[0] ^= a[1]; //this is working correctly. a[0] ^= a[1] ^= a[0] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
JOptionPane.showMessageDialog is not working on tomcat however it is working on netbeans on same machine
JOptionPane.showMessageDialog is not working on tomcat however it is working on netbeans on same machine  the following code is not running on apacheTomcat 7.0.30 version but the same code is working on netebans 7.0, how to make
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2...] ^= a[0]; //a[0] ^= a[1]; //this is working correctly. a[0] ^= a[1] ^= a[0] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
Why PHP ?
Why PHP? Reasons to use PHP are given below: 1.    PHP is open... access to the source code, it has following features also: Free Redistribution Source Code Derived Works Integrity of the author's source
Why System class not in jsp - JSP-Servlet
Why System class not in jsp  Hi Friends, why system.out.println("") not working in jsp . But out.println is working I want the reason pz . Thanks Prakash
stuts java script validation is not working.
stuts java script validation is not working.  hello my stuts client side validation is not working. pls help me out i have put jsp file's code and validation.xml file's code. pls help --of jsp page
stuts java script validation is not working.
stuts java script validation is not working.  hello my stuts client side validation is not working. pls help me out i have put jsp file's code and validation.xml file's code. pls help --of jsp page-- > <html:form action
Working with CSS(CSS Manipulation)
Working with CSS(CSS Manipulation)       Working with CSS(CSS Manipulation...;); }); </script> Above code display
working wit string - Java Beginners
working wit string  accept a paragraph of text. consisting of sentences that are terminated by either '.' or '?' or '!' followed by a single space... code: import java.util.*; import java.util.regex.*; public class
SubCombo box not working - Development process
SubCombo box not working  Hi, in the following code subcombo box is not working and while storing combo box numbers(1,2,3) are stored instead of values. Search Page var arr = new Array(); arr[0] = new
Why do we use ORM?
Why do we use ORM?  Why do we use ORM?   ORM is technology to access the data from the database. With the help of ORM framework, business... contain feature of query language. · ORM provides less error-prone code
Why Outsource Work - Read Why Need of Outsourcing Services
Outsourcing : Why Outsource Work? Introduction Many businesses, big and small alike, go for outsourcing these days. There are many benefits derived from... of access to expertise in each area of work, larger number of people working
Java runtime not working - Java Beginners
of SwingFrame() therefore you have got that error.Anyways, here is your code
Why Outsourcing, Why Outsourcing Service, Why Outsourcing Work
Why Outsource? Introduction Different firms have different specific business situations that call for outsourcing. Some organizations take to outsourcing.... These vendors have gained expertise working with many clients facing different
Why tiny HTML Tools?
Why tiny HTML Tools?       The Plug-In, as the name suggests, offers some tiny tools for working with HTML. It was written with the typical experience of generating
Why Open Source?
Why Choose Open Source?      ... the source code to their specific needs. These people improve the software, take... and hand out additions, code fixes, bug reports and documentation for the software
Mutiple part is ot working - JSP-Servlet
. But in one system when i use enctype="mutlipart" its working but in other system its not working. Is this a problem with the browser or nything else... code where you having the problem and visit to : http://www.roseindia.net