Hi,
I am programming an in memory representation of a database and am at
the tail end, hopefully, of implementation. But the vexing point is
that my program runs fine with all my diagnostic printf statements, but
as soon as I remove the printf statements the program crashes with a
pointer error (usually tried reading x00000000 error).
I have tried everything from flushing the buffer, tracking done the
routine, etc... can anyone offer me some suggestions to something I
might try? Has anyone had a similiar error? What is going on with
printf that would cause the removal of it to prvent program execution?
Does printf empty a buffer that is overflowing? Please excuse my
lamentations but I've hit my head against this for almost 2 days.
Thank you in advance for any response. 14 6840
Hi Harman,
I'm not the world's best expert, but in my experience whenever you
have anomalies like this it suggests that dynamically allocated memory
is corrupt. Look closely to make sure everything that needs to be
allocated is allocated before use and that once anything is free'd, it
is never "used" again.
Harman Dhaliwal wrote: Hi, I am programming an in memory representation of a database and am at the tail end, hopefully, of implementation. But the vexing point is that my program runs fine with all my diagnostic printf statements, but as soon as I remove the printf statements the program crashes with a pointer error (usually tried reading x00000000 error).
I have tried everything from flushing the buffer, tracking done the routine, etc... can anyone offer me some suggestions to something I might try? Has anyone had a similiar error? What is going on with printf that would cause the removal of it to prvent program execution? Does printf empty a buffer that is overflowing? Please excuse my lamentations but I've hit my head against this for almost 2 days. Thank you in advance for any response.
"Snis Pilbor" <sn********@yah oo.com> wrote in message Hi Harman,
I'm not the world's best expert, but in my experience whenever you have anomalies like this it suggests that dynamically allocated memory is corrupt. Look closely to make sure everything that needs to be allocated is allocated before use and that once anything is free'd, it is never "used" again.
Harman Dhaliwal wrote: Hi, I am programming an in memory representation of a database and am at the tail end, hopefully, of implementation. But the vexing point is that my program runs fine with all my diagnostic printf statements, but as soon as I remove the printf statements the program crashes with a pointer error (usually tried reading x00000000 error).
I have tried everything from flushing the buffer, tracking done the routine, etc... can anyone offer me some suggestions to something I might try? Has anyone had a similiar error? What is going on with printf that would cause the removal of it to prvent program execution? Does printf empty a buffer that is overflowing? Please excuse my lamentations but I've hit my head against this for almost 2 days. Thank you in advance for any response.
Mr. Pilbor, please don't top post. Have you (OP) been keeping an eye of the
return value on printf? joe
Harman Dhaliwal schrieb: Hi, I am programming an in memory representation of a database and am at the tail end, hopefully, of implementation. But the vexing point is that my program runs fine with all my diagnostic printf statements, but as soon as I remove the printf statements the program crashes with a pointer error (usually tried reading x00000000 error).
I have tried everything from flushing the buffer, tracking done the routine, etc... can anyone offer me some suggestions to something I might try? Has anyone had a similiar error? What is going on with printf that would cause the removal of it to prvent program execution? Does printf empty a buffer that is overflowing? Please excuse my lamentations but I've hit my head against this for almost 2 days. Thank you in advance for any response.
This is one downside of undefined behaviour - it might even seem to
work, until you remove this call to printf(). So your real mistake
happened somewhere before the printf() was called while your program was
executing.
--
Marc Thrun http://www.tekwarrior.de/
I haven't been keeping track, but if a negative number is returned, how
can i use this to track my error? I am relatively new to C and am
approaching from a high level language (java) background ha*******@gmail .com said: I am relatively new to C and am approaching from a high level language (java) background
The cause of your C problem is an error in the way you are using pointers.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
"Richard Heathfield" ha*******@gmail .com said:
I am relatively new to C and am approaching from a high level language (java) background
The cause of your C problem is an error in the way you are using pointers.
Did the claim that printf managed to print a negative number of characters
figure into this diagnosis? joe
"Joe Smith" <gr**********@n etzero.net> writes: "Richard Heathfield" ha*******@gmail .com said:
I am relatively new to C and am approaching from a high level language (java) background
The cause of your C problem is an error in the way you are using pointers.
Did the claim that printf managed to print a negative number of characters figure into this diagnosis? joe
I don't recall any such claim.
printf() returns the number of characters printed, or a negative value
if an error occurs. Even if it were possible for it to print a
negative number of characters, there would be no way for it to
indicate that it had done so.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Joe Smith said: "Richard Heathfield" ha*******@gmail .com said:
I am relatively new to C and am approaching from a high level language (java) background
The cause of your C problem is an error in the way you are using pointers.
Did the claim that printf managed to print a negative number of characters figure into this diagnosis?
No, my diagnosis was based on the fact that the OP has a Java background.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Harman Dhaliwal wrote: Hi, I am programming an in memory representation of a database and am at the tail end, hopefully, of implementation. But the vexing point is that my program runs fine with all my diagnostic printf statements, but as soon as I remove the printf statements the program crashes with a pointer error (usually tried reading x00000000 error).
I have tried everything from flushing the buffer, tracking done the routine, etc... can anyone offer me some suggestions to something I might try? Has anyone had a similiar error? What is going on with printf that would cause the removal of it to prvent program execution? Does printf empty a buffer that is overflowing? Please excuse my lamentations but I've hit my head against this for almost 2 days. Thank you in advance for any response.
How can we debug code you don't show? Seriously.
When something like that happens, you are probably overwriting some
automatic data or something like that.
Reduce it to a minimal, compilable program that demonstrates the
problem. Often you'll find it yourself when you do that. Otherwise,
post the code.
Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: gopal srinivasan |
last post by:
Hi,
I have a text like this -
"This is a message containing tabs and white spaces"
Now this text contains tabs and white spaces. I want remove the tabs
and white spaces(if it more than once between two words).
Is there any function we have in C which will find out the tabs and
white spaces and returns the...
|
by: aditya |
last post by:
hi,
Can anybody please tell me that how the following printf(...)
statement works-
main(){
int d=9;
printf("%d",printf("%d"));
return 0;
|
by: Eric Lilja |
last post by:
Hello, I have two code snippets I want you to look at. My program compiles
without warnings (warning level set to max, gcc 3.4.3) with either snippet
but the latter one causes a segfault at run-time. I know it contains
non-standard constructs (using the MySql C api) but I wanted to know if it's
printf() I'm misuing. Here are the snippets:
...
|
by: biras |
last post by:
hi
#include<stdio.h>
void main( )
{
char *p;
p="yes";
printf(p);
|
by: tom fredriksen |
last post by:
Hi
I was doing a simple test of the speed of a "maths" operation and when I
tested it I found that removing the loop that initialises the data array
for the operation caused the whole program to spend twice the time to
complete. If the loop is included it takes about 7.48 seconds to
complete, but when removed it takes about 11.48 seconds.
...
| |
by: timmu |
last post by:
Someone asked me a question about integer division and printf
yesterday,
I tell him he should do a casting to float/double before you do any
interger division.
But he doesn't think so, so I try to do some example to explain,
However, after some trying,
I confused when I try to do some integer constant division,
I know I should do float...
|
by: RedDevilDan |
last post by:
I am working on a Memory Footprint Reduction project. I came across an
idea to disable all printf statements so that less memory is required.
In addition, when there is no single printf statement, the printf
library will not be linked, so it further reduces the executable size.
Is there an easy way to disable printf in a large project? In my...
|
by: sam_cit |
last post by:
Hi Everyone,
int main()
{
printf("not included stdio.h");
}
Yes, i haven't included stdio.h and my compiler would generate a
warning and would assume that it would return a int, my question is how
does the linker manage to link the function invocation to the proper
|
by: candy_init |
last post by:
Hi all,
I just came across the following program:
#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |