473,549 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FormatMessage and va_list args

Hi,

I have a function that has a variable no of arguments
(note! function shortened)

myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'.

How can I correctly pass this all since the code above does not work.
Nov 17 '05 #1
4 2688
> myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'. How can I correctly pass this all since the code above does not work.

What do you mean by "does not work".
What is the behavior? Does not compile? Crashes?

--
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Nov 17 '05 #2
It works fine. But I think you may need to read FormatMessage's
documentation again.

Nov 17 '05 #3
"Mihai N." <nm************ **@yahoo.com> wrote in message
news:Xn******** **********@207. 46.248.16...
myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'.

How can I correctly pass this all since the code above does not work.

What do you mean by "does not work".
What is the behavior? Does not compile? Crashes?


OK,

Solved.

I assumed that %s would be recognized as well. It should be %1 :)

Nov 17 '05 #4
"Mihai N." <nm************ **@yahoo.com> wrote in message
news:Xn******** **********@207. 46.248.16...
myfunction(int someID, ...)

{
va_list args;
va_start args, someID;
FormatMessage(. ....., &args);
va_end(args);
}

PROBLEM: formatMessage wants a pointer thus, 'va_list *Arguments'.

How can I correctly pass this all since the code above does not work.

What do you mean by "does not work".
What is the behavior? Does not compile? Crashes?


garbled output.
Nov 17 '05 #5

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

Similar topics

2
4710
by: Andrej Prsa | last post by:
Hi! If I declare two functions like this: int execute_command (char *name, ...) { va_list args; va_start (args, name); my_func (1, args);
7
4722
by: Jon | last post by:
Is it possible to modify an argument of a va_list and then pass the modified va_list to other functions? void c_fun1(int, va_list args) { int *firstIntPointer = &(va_arg(args, int)); *firstIntPointer = 2; // a new value }
11
3051
by: thierrydollar | last post by:
Hi, I have written a very simple program using variable arguments calls and I get strange things that I cannot explain. I have one function (add) that displays two parameters. It works well when I call it directly. Now I have a second function (set) that also calls add. But this doesn't
12
1852
by: Volte | last post by:
Hey, wondering if there is a va_list equivalent in Javascript. Well, actually, I know that there is, but I don't know if its user... applicable. va_list in C/++ anyhow is a way of being able to pass in any number of arguments at the end of a function, I'll show an example: Header: void addLine(int, const char*, ...); cpp:
1
9447
by: skillzero | last post by:
Is there a portable way to pass a va_list as a parameter to another function taking a variable argument list? I have a function that takes a printf-like format string and I'd like to use something like %V to pass in another format string and a va_list to allow nesting. It happens to work on my compiler, but I wasn't sure if it's portable to...
4
19228
by: Tor Rustad | last post by:
I have a C program, where I control the error behavior according to context: /* some error handlers */ static void on_error_log (MYSQL *mysql, const char *msg, ...); .... static void on_error_exit (MYSQL *mysql, const char *msg, ...); /* the error function */ static void (*error_fatal) (MYSQL *mysql, const char *msg, ...) =
8
2763
by: Fred | last post by:
I've got following program encapsuled fscanf, however, it doesn't work. I'm sure that the content format in "a.txt" is OK, the content would be correctly read if using fscanf directly, what's wrong with my program? Thanks for help! int vsscanf( FILE* fp, const char *fmt, ... ) { va_list arglist; va_start( arglist, fmt );
5
4636
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On Jun 3, 3:23 am, Jesse Ziser <d...@spam.diewrote: The relevant paragraph from the Standard is: ---- Begin Quote ---- The type declared is va_list which is an object type suitable for holding information needed by the macros
2
4228
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
There are tons of examples of how to call FormatMessage from C# on the internet, but none of these pass insertions strings to the FormatMessage. Is there an example of how this should work? My DllImport currently looks like this. This doesn't seem correct to me since the 7th parameter is a va_list *. It would be nice to be able to pass...
0
7527
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
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...
0
7726
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7819
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3505
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...
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
bsmnconsultancy
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...

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.