473,473 Members | 4,297 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Examine the following!!

2 New Member
#include <stdio.h>
#include <string.h>
int main()
{
printf("%s\n", strerror(2));
return 0;
/*indicates successful termination */
}/*end main*/

What is the above demonsrating?

A, a function takes an error number and creates an error message string
B,A function takes a string as an argument and returns the number of characters in the string.
C,A function copies the value of the byte and includes it as an error in the printf.
D,None above

I got this question wrong and I like to corrrect myself plz help.
Nov 3 '09 #1
4 1548
donbock
2,426 Recognized Expert Top Contributor
@gasteven
What [wrong] answer did you give before?
Nov 3 '09 #2
gasteven
2 New Member
I put A and it was wrong! I like to know the right answer.
Nov 3 '09 #3
newb16
687 Contributor
The correct answer still is A). It demonstrates usage of strerror() that "takes an error number and creates an error message string" which you can check in any C reference. ( just google for strerror). No part of this code "returns the number of characters in the string" or "function copies the value of the byte and includes it as an error" ( e.g. because int as a strerror's argument is not a byte)
Nov 3 '09 #4
donbock
2,426 Recognized Expert Top Contributor
@gasteven
@gasteven
I assume the point of the question is to describe what main does.

You need to familiarize yourself with standard library function strerror. Your program creates the error message string corresponding to error number 2; and then prints that error message string to stdout.

Consider answer A: a function takes an error number and creates an error message string. This is pretty close. Your program is hard coded for error number 2. Your program prints the error message string after creating it.

Consider answer B: a function takes a string as an argument and returns the number of characters in the string. This can't be right because your function doesn't have any arguments.

Consider answer C: a function copies the value of the byte and includes it as an error in the printf. This can't be right because the error number value ("2") is not present in the printed text.

Consider answer D: none of the above. This is a possibility. It depends on whether the instructor considers the exceptions noted above for answer A to be significant.
Nov 3 '09 #5

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

Similar topics

1
by: Kim Lots | last post by:
Hi I'm trying to figur out how to examine variables at run time. For instance I have the following code --lot of code here above For Each Count In Request.Form("box")
9
by: VBS Programer | last post by:
I am working with a thermal printer that returns it's status in a string. In vb6.0 I would use the MidB,AscB functions to examine the first 32 bits. What can I use in vb.net to do the same.
8
by: MLH | last post by:
Have a look at the procedure below. In particular, note lines 1 and 21... Private Sub JudHrngReqBtn_Click() On Error GoTo Err_JudHrngReqBtn_Click Dim ThisForm As String ThisForm = Me.Name ...
2
by: tom | last post by:
Hello I was wondering what happens when one declares 2 arrays: private object arr1; private object arr2; fills them appropriately and then writes: arr1 = arr2;
4
by: help | last post by:
If I enable debug at C# exceptions, it dutifully breaks and shows me the stack of called procedures. At the top (of my list) is DateTime.ParseExact() and it does through an exception if I proceed....
1
by: Richard A. Lowe | last post by:
I have a non-COM, non-.NET DLL, apparently written in C++ but for which there is no source available (so I am told). I have tried the DumpBin utility and Dependancy Walker to examine the exported...
2
by: Robert W. | last post by:
I'm trying to write a utility that will use Reflection to examine any data model I pass it and correctly map out this model into a tree structure. When I say "any" , in fact there will only be 3...
1
by: Edward Wilde | last post by:
Hi, Does anyone know how to examine items in the ASP.NET cache that are added using the OutputCache directive in framework 1.1 i.e. <%@ OutputCache Duration="300" VaryByParam="None"...
1
by: Brian | last post by:
Hello - I would like to examine the contents of a dataset at runtime to check that a query is returning the right data. I have set a breakpoint at the appropriate spot, but I am unsure as to...
6
by: dba | last post by:
using the following code with a problem.... echo "<input type='hidden' name='member_id' value=\"{$row}\">{$row}"; echo "<input type='radio' name='member_name' value=\"{$row}\">{$row}<br />"; ...
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
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,...
1
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
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.