473,397 Members | 2,084 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.

General advice on type casting

Dear all,

Here is a sample of my code:
----------------------------------------------
void message_is(gchar *ff, int d, gchar *o){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o);
Sol_print_infos(texte); /* g_free(texte) */;
}

void message_sd(gchar *ff, gchar *d, double o){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o);
Sol_print_infos(texte); /* g_free(texte) */;
}

void message_iii(gchar *ff, int d, int o, int t){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o ,t);
Sol_print_infos(texte); /* g_free(texte) */;
}
----------------------------------------------
where you can guess that Sol_print_infos is the
guy that does the actual printing with style
and all.
I haven't been able to put all of them in one
piece of code. (And I have more !!). Efficiency
in terms of time is faily irrelevant at this
level.
Thanks in advance !
Amities,
Olivier
Aug 31 '06 #1
2 1382
Olivier wrote:
Dear all,

Here is a sample of my code:
----------------------------------------------
void message_is(gchar *ff, int d, gchar *o){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o);
Sol_print_infos(texte); /* g_free(texte) */;
}

void message_sd(gchar *ff, gchar *d, double o){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o);
Sol_print_infos(texte); /* g_free(texte) */;
}

void message_iii(gchar *ff, int d, int o, int t){
gchar *texte = NULL;
texte = g_malloc(256);
g_snprintf(texte, 256, ff, d, o ,t);
Sol_print_infos(texte); /* g_free(texte) */;
}
----------------------------------------------
where you can guess that Sol_print_infos is the
guy that does the actual printing with style
and all.
I haven't been able to put all of them in one
piece of code. (And I have more !!). Efficiency
in terms of time is faily irrelevant at this
level.
Thanks in advance !
Amities,
Olivier
void message(char *fmt,...)
{
char *texte;
va_list ap;

texte = malloc(256);
if(texte != NULL) {
va_start(ap,fmt);
vsnprintf(gtexte, 256, fmt, ap);
va_end(ap);
Sol_print_infos(texte);
free(texte);
}
}
Aug 31 '06 #2
Nils O. Selåsdal a écrit :
void message(char *fmt,...)
{
char *texte;
va_list ap;

texte = malloc(256);
if(texte != NULL) {
va_start(ap,fmt);
vsnprintf(gtexte, 256, fmt, ap);
va_end(ap);
Sol_print_infos(texte);
free(texte);
}
}
Wouah :-] Sounds amazing !
Investigating !
Thanks, O.
Aug 31 '06 #3

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

Similar topics

4
by: Jacob Jensen | last post by:
This question has probably been asked a million time, but here it comes again. I want to learn the difference between the three type cast operators: static_cast, reinterpret_cast, dynamic_cast. A...
11
by: Michael B. | last post by:
I'm still learning C so I've written a simple app which lets you make a contact list (stored as a linked list of structs), write it to a file, and read it back. It works fine, but I notice in my...
5
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a creating a my own tabpage class (MyTabPage) which inherits the .Net TabPage class. In the relevant event I want to loop through the collection of TabPages and then when I...
10
by: Bob | last post by:
This has been bugging me for a while now. GetType isn't availble for variables decalred as interface types, I have to DirectCast(somevariable, Object). In example: Sub SomeSub(ByVal...
23
by: René Nordby | last post by:
Hi there, Is there anyone that knows how to do the following? I have a class A and a class B, that 100% inherits from class A (this means that I don't have other code in class B, than...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
66
by: KimmoA | last post by:
Hey! Some questions about C that have been bugging me for a while... 1) Is inline a valid C keyword or not? I was kind of surprised of not finding it in C, to be honest. My "The C Programming...
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
3
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have some problems with Crystal Reports (Version 10.2, Runtime 2.0). In Section3 I have added a OLE Object (Bitmap). Now when I open the report in my code I would like to set this...
3
by: Anders Borum | last post by:
Hello, I've worked on an API for quite some time and have (on several occasions) tried to introduce generics at the core abstract level of business objects (especially a hierarchical node). The...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.