473,378 Members | 1,372 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,378 software developers and data experts.

my own type, print function

Hi,

i have created an own type in C and have implemented
the print function for it.

static int mytype_print(mytype_obj* self, FILE* fp, int flags) {
printf("[%p]", fp);
fprintf(fp, "Hello, world\n");
}

At the moment i ignore "flags". The first line "printf" is
executed, fp is NOT Null. But i haven't yet explored the memory
at that location. At the moment it points to 7803BB68.

The second line "fprintf" crashes the program.
The command at 0x77f88216 points to 0x00000010. The action
"written" could not be executed. (I translated that from german).
If i delete the second line, the program runs normally,
as i'd expect it.
Can anybody give me a hint what could be wrong here?
Best regards,
Torsten.

Jul 18 '05 #1
2 1454
Torsten Mohr <tm***@s.netic.de> writes:
Hi,

i have created an own type in C and have implemented
the print function for it.


I'm not sure what your problem is, but my advice is: don't do that :)

I.e. don't fill out the tp_print slot of your type object unless your
object type has such a long printed representation that going via a
string representation is grossly inefficent.

Cheers,
mwh

--
"Sturgeon's Law (90% of everything is crap) applies to Usenet."
"Nothing guarantees that the 10% isn't crap, too."
-- Gene Spafford's Axiom #2 of Usenet, and a corollary
Jul 18 '05 #2
Hi,
i have created an own type in C and have implemented
the print function for it.


I'm not sure what your problem is, but my advice is: don't do that :)

I.e. don't fill out the tp_print slot of your type object unless your
object type has such a long printed representation that going via a
string representation is grossly inefficent.


Ok, i'll try that, but i still wonder why it crashes my python
interpreter. I'd like to understand that, also, i can't see what
COULD be wrong, i just do a normal fprintf() on the FILE* that
i get as a parameter.
Best regards,
Torsten.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Terje Slettebų | last post by:
Hi. I'm new here, and sorry if this has been discussed before; I didn't find it searching the PHP groups. (I've also read recommendations to cross-post to the other PHP groups, but if that is...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
1
by: Gilles Arnaud | last post by:
Hello, I've got a nasty bug and no idea to deal with : here is the method : <method> def denormer(self, var) : " denorme un vecteur d'entree " try: #a = map(self.decerner, self.param, var)
5
by: Paul Rubin | last post by:
Oh well. I had wanted to be able to define two functions f and g, and have f*g be the composition of f and g. >>> func_type = type(lambda: None) >>> class composable_function(func_type): ... ...
5
by: AMDRIT | last post by:
I would like to cast an object to a value type specified by a variable of Type Function ReturnTest(InputVar as Object) as Object Dim DataType as Type = GetType(System.String) If TypeOf...
15
by: Paddy | last post by:
Hi, I am trying to work out why I get UnboundLocalError when accessing an int from a function where the int is at the global scope, without explicitly declaring it as global but not when accessing...
8
by: WakeBdr | last post by:
I'm writing a class that will query a database for some data and return the result to the caller. I need to be able to return the result of the query in several different ways: list, xml,...
0
by: anuptosh | last post by:
Hi, I have been trying to run the below example to get a Oracle Array as an output from a Java code. This is an example I have found on the web. But, the expected result is that the code should...
3
by: .rhavin grobert | last post by:
guess you have the following: _________________________________________________ template <class T> class CQVector { public: // find an element, returns index or -1 if none is found int...
0
by: skip | last post by:
(Sorry for any repeated recommendations. I'm offline until Monday morning. You may well see some of these suggestions in the meanwhile, but so far it seems you've had no nibbles.) MartinI'm...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.