Search 5,000,000+ questions and answers.

Frequently Asked Questions

How can I call a non-system C function f(int,char,float) from my C++ code?

How to mix C and C++, C++ FAQ Lite
If you have an individual C function that you want to call, and for some reason you don't have or don't want to #include a C header file in which that function is declared, you can declare the individual C function in your C++ code using the extern "C" syntax. Naturally you need to use the full function prototype:
Related Questions

How can I create a C++ function f(int,char,float) that is callable by my C code?

How to mix C and C++, C++ FAQ Lite
The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern "C" construct: The extern "C" line tells the compiler that the external information sent to the linker should use C calling conventions and name mangling (e.g., preceded by a single underscore). Since name overloading isn't supported by C, you can't make several overloaded functions simultaneously callable by a C program.
Related Questions

How to convert an int to a char array or C++ string?

Tech Talk about C++ and C Issues / Comeau C++ and C FAQ
How to add a float (or "any" type really) to the end of a C++ string? Unlike routines like atoi mentioned in the previous question, there is no direct routine such as itoa available. However, similar to the string I/O routines in the previous question, one can do this: #include <stdio.h> // cstdio in C++ // ..
Related Questions

Can I use standard data types like int, float and char with Vector class?

Java Language FAQs
No. You cannot use them as Vector deals with objects. Standard data types are not objects. However, you can use wrapper classes to convert standard data types to object so that they can be used with Vector. Vector v = new Vector(); // v.add(10); -- cannot be done v.add ( new Integer(10)); // int 10 is converted to object of type Integer class.
Related Questions

Why doesn't the code int a = 1000, b = 1000; long int c = a * b; work?

The C Language FAQ
Under C's integral promotion rules, the multiplication is carried out using int arithmetic, and the result may overflow and/or be truncated before being assigned to the long int left- hand-side. Use an explicit cast to force long arithmetic: long int c = (long int)a * b; In 1983, the American National Standards Institute commissioned a committee, X3J11, to standardize the C language.
Related Questions

E3. How can I call a C function?

Icon Programming Language FAQ
You can't call an arbitrary C function, but you can load and call one that is written to Icon's specifications. A tutorial appears in Icon Analyst 36. Some examples can be found in the cfuncs and packs/loadfuncs directories of the Icon program library. The Jcon implementation allows Icon programs to call Java code that is written to Jcon specifications.
Related Questions

Section 11. Stdio 11.1: Why doesn't this code: char c; while((c = getchar()) != EOF)... work?

The C Language FAQ
For one thing, the variable to hold getchar's return value must be an int. getchar can return all possible character values, as well as EOF. By passing getchar's return value through a char, either a normal character might be misinterpreted as EOF, or the EOF might be altered and so never seen. References: CT&P Sec. 5.1 p. 70.
Related Questions

What's the deal on sprintf's return value? Is it an int or a char *?

Stdio
The Standard says that it returns an int (the number of characters written, just like printf and fprintf). Once upon a time, in some C libraries, sprintf returned the char * value of its first argument, pointing to the completed result (i.e. analogous to strcpy's return value).
Related Questions

Can I drop the [] when deleteing array of some built-in type (char, int, etc)?

Freestore management, C++ FAQ Lite
Sometimes programmers think that the [] in the delete[] p only exists so the compiler will call the appropriate destructors for all elements in the array. Because of this reasoning, they assume that an array of some built-in type such as char or int can be deleted without the []. E.g., they assume the following is valid code: But the above code is wrong, and it can cause a disaster at runtime.
Related Questions

How can I convert an INT into CHAR*/STRING or vice versa?

Beginner FAQ - GPWiki
This is something you do a lot in programming and pretty much every language makes it easy to convert between types. You may have already printed integers to the console with COUT or PRINTF, which of course needs to be converted to a string first. Converting numbers to strings is done in a similar way. Boost is a C++ library that can help you with problems like these and many others.
Related Questions

Why can't I pass a char ** to a function which expects a const char **?

ANSI/ISO Standard C
You can use a pointer-to-T (for any type T) where a pointer-to-const-T is expected. However, the rule (an explicit exception) which permits slight mismatches in qualified pointer types is not applied recursively, but only at the top level. (const char ** is pointer-to-pointer-to-const-char, and the exception therefore does not apply.) The reason that you cannot assign a char ** value to a const char ** pointer is somewhat obscure.
Related Questions

ANSI
You can use a pointer-to-T (for any type T) where a pointer-to- const-T is expected, but the rule (an explicit exception) which permits slight mismatches in qualified pointer types is not applied recursively, but only at the top level. You must use explicit casts (e.g. (const char **) in this case) when assigning (or passing) pointers which have qualifier mismatches at other than the first level of indirection.
Related Questions

Is C++ a superset of C? Can I use a C++ compiler to compile C code?

Infrequently Asked Questions in comp.lang.c
C++ is a superset of something, we're not sure what. You can use a C++ compiler to compile C code, but the results may surprise you.
Related Questions

How can I include a non-system C header file in my C++ code?

How to mix C and C++, C++ FAQ Lite
If you are including a C header file that isn't provided by the system, you may need to wrap the #include line in an extern "C" { /*...*/ } construct. This tells the C++ compiler that the functions declared in the header file are C functions. Note: Somewhat different guidelines apply for C headers provided by the system (such as <cstdio>) and for C headers that you can change.
Related Questions

What is the difference between an expenditure function code and an expenditure type?

FM FAQs
The expenditure function is the overall purpose for which a project exists. It is an attribute assigned to the project when it is created. In their financial statements, public institutions are required to classify expenditures by function. The following functional classifications are derived from the Financial Accounting and Reporting Manual for Higher Education. For a complete list of expenditure function codes, click here.
Related Questions

What is a function code?

Simply Modbus - Data Communication Test Software - FAQ
Each slave in a network is assigned a unique address from 1 to 247. When the master requests data, the first byte it sends is the Slave address. This way each slave knows after the first byte whether or not to ignore the message. The second byte sent by the Master is the Function code. This number tells the slave which table to access and whether to read from or write to the table.
Related Questions

How do I enter a function such as f(x) ?

Algebra Toolkit
At this time Algebra Toolkit does not support functional notation. However, if you just want to graph a function, use this notation y = ... (i.e. y=2x-3)
Related Questions

What should the code "int i = 3; i = i++;" do?

Frequently Asked Questions: C Language (abridged)
Operator precedence and explicit parentheses impose only a partial ordering on the evaluation of an expression, which does not generally include the order of side effects.
Related Questions

Why the name CrossFire and why are the C and the F both capitalized?

Info: ATI's CrossFire - Overclock.net - Overclocking.net
No idea, but that's how it was in the press release (yes I read all the technical docs and the press release so everything I say henceforth is to be considered the absolute, no BS, truth as of 6/1/05 (today).
Related Questions

What's the best style for code layout in C?

Infrequently Asked Questions in comp.lang.c
There are many systems of indentation advocated, but all of them have the same basic flaw; they will mislead the reader when the actual code logic does not follow the indentation. It is better to avoid indentation entirely, so the reader will not be misled.
Related Questions

What is a char?

jGuru: I18N FAQ Home Page
While the char type is basic to the Java language, many programmers stumble over Unicode escapes, values and conversions. The first definition should...
Related Questions

How can I make a keyboard input function that allows you to bring up the CHAR menu (or MATH, etc)?

Frequently Asked Questions
I really need a routine like InputStr given above, but which is able to bring up the CHAR dialog. However, I am not able to make such routine by myself... I received a lot of such questions. These questions are usually asked by newbie programmers, but the answer is quite advanced. Although I don't like to present advanced routines as-is without a lot of necessary explanations, I am requested to do so.
Related Questions

I want to use a char * pointer to step over some ints. Why doesn't "((int *)p)++;" work?

Frequently Asked Questions: C Language (abridged)
In C, a cast operator is a conversion operator, and by definition it yields an rvalue, which cannot be assigned to, or incremented with ++. I have a function which accepts, and is supposed to initialize, a pointer, but the pointer in the caller remains unchanged.
Related Questions

Do I have to assign an expenditure function classification code to all my departmental projects?

FM FAQs
All accounts that currently exist in FAS already have an expenditure function code assigned to them, and this code will transfer to the Integrated System as part of the conversion process. After go-live (July 2), the project manager will assign the expenditure function code at the time a project is created. As part of the Integrated System's workflow, the expenditure function assigned to the project will be reviewed by a Central approver.
Related Questions

How can I code in C++ if I do not know C?

Programming in C and C++: Frequently Asked Questions (FAQ)
The C programming language is a full subset of the C++ programming language. Though the programming paradigms are different for the languages (C advocates procedural programming paradigm while C++ advocates object-oriented programming paradigm), basic programming language constructs are similar.
Related Questions

Is there a dress code for my non-classroom hours?

Job Corps - West Coast Region
The dress code for after-trade hours is more relaxed, with sweat pants, jeans and shorts being allowed. Too many of one color in one's attire is never allowed, nor is sagging and drug- or gang-related writing on clothing. Flip-flops cannot be worn outside the dormitory.
Related Questions

How do I convert a string to a double or int? What plays the role of atof and atoi in C#?

Windows Forms FAQ - Windows Forms from MFC
You use static members of the Convert class found in the System namespace to handle conversions in the .NET framework.
Related Questions

c In a call to malloc, what does an error like ''Cannot convert 'void *' to 'int *''' mean?

All Questions
I wrote a little wrapper around malloc, but it doesn't work: #include <stdio.h> #include <stdlib.h> mymalloc(void *retp, size_t size) { retp = malloc(size); if(retp == NULL) { fprintf(stderr, "out of memory\n"); exit(EXIT_FAILURE); } } I'm trying to declare a pointer and allocate some space for it, but it's not working.
Related Questions

Got A Question? Ask Our Community!


More Questions >>

© Copyright 2007-2008 QueryCAT
About • Webmasters • Contact