473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

c code is dumping

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main () {
  6.     char *temp;
  7.     int size = 1396899840;
  8.     temp = (char *) malloc (size);
  9.  
  10.     if (!temp) {
  11.         fprintf (stderr, "Error in allocating memory");
  12.         exit (-1);
  13.     }
  14.     memcpy (temp, "Jagadeesha",size);
  15.     printf ("temp : %s", temp);
  16. }
Feb 9 '10 #1
2 1326
what is solution for this
Feb 9 '10 #2
Banfa
9,065 Expert Mod 8TB
At line 14 don't try to copy 1396899840 from a data object that is only 11 bytes long. As soon as you access data outside the valid object boundaries your program invokes underfined behaviour one of the possibilities of which is a program crash.
Feb 9 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kamal | last post by:
I am trying to dump a hash using Data::Dumper. I need to quote the keys while dumping. My progarm looks like this use Data::Dumper; $Data::Dumper::Quotekeys = 1; $Data::Dumper::Useqq = 1; ...
3
by: kerri | last post by:
Hi, I need to do a mysqldump of specific inserts, updates & deletes. I read in the docs that I can use -w or --where. Can I do a join? Could someone provide an example? Is there another...
6
by: Greg Brant | last post by:
Hi, how can i backup a table / entire DB and get the index's as well as the data / create table's etc cheers Greg
4
by: rozrabiak | last post by:
Hi:) I need to dump data from database in to *.sql file. I try it using DUMP DATABASE but it not work that I need it. So, how can I dump data from database in to *.sql file and then run it...
10
by: ken | last post by:
hello, i'm writing a c program on a linux system. i'm debugging a segmentation fault but i don't want it to dump a core file because the memory footprint of the program is over 300Mb and i don't...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
2
by: VMI | last post by:
How can I dump a datatable into an Access table (which contais exactly the same structure)? Somebody suggested doing this with a dataAdapter. I don't want to run an Insert query for each record (I...
0
by: xpcer | last post by:
i was have an error when i dumping an database using mysql, this is the message: mysqldump: Got error: 1146: Table '↑╪◄ .v_sp_buku_dipinjam_denda' doesn't exist when using LOCK TABLES can...
13
by: gonzlobo | last post by:
Greetings, and happyNewYear to all. I picked up Python a few weeks ago, and have been able to parse large files and process data pretty easily, but I believe my code isn't too efficient. I'm...
7
by: gomzi | last post by:
hi, I would like to know the command for dumping stored procedures. Thought that I knew the command and dumped the db using the -R option, only to realise that dumping of procedures had failed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.