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

What is void type how can we use it?

What is void type how can we use it?
Aug 9 '10 #1
1 1843
donbock
2,426 Expert 2GB
Are you asking about C or C++?

Off hand, I can think of four ways the void keyword is used in C:
  1. In a function prototype and function definition, this keyword is used to indicate that the function does not have a return value.
  2. In a function prototype and function definition, this keyword is used to indicate that the function does not have any arguments.
  3. Pointer-to-void is used to define/declare a generic pointer that is large enough to hold any pointer value.
  4. A function call can be cast to void as a sort of comment that you know the function has a return value but that you are deliberately ignoring it.
Expand|Select|Wrap|Line Numbers
  1. #1:
  2. void func1(int);
  3.  
  4. #2:
  5. int func2(void);
  6.  
  7. #3:
  8. void *p;
  9.  
  10. #4:
  11. (void) printf("hello world\n");
C++ would have all these, plus perhaps some additional usages that I don't know about.
Aug 9 '10 #2

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

Similar topics

2
by: Stub | last post by:
If building a list of elements of void * type, this way different pointer types of objects can be put in the list. When you pop data from the list, can RTTI or any other method be used to...
3
by: Tee | last post by:
Hi guys, I have a problem with my VS project, it keeps saying COM Interop registration failed. Could not find a type library for assembly 'Class1'. If I choose to continue, everything still work...
4
by: LordHog | last post by:
Hello all, I am having a little problem getting my (void *) assignment to work correctly. Basically it is some code for a circular queue buffer I am trying to implement, but getting the...
2
by: MFRASER | last post by:
How can I tell what object type is dropped onto my control? Here is a snippet of code. private void lvwTasks_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //I want to...
2
by: Judah | last post by:
With generics in .NET 2, there are certain scenarios in which using System.Void would be useful: TReturnType MyFunction<TReturnType>() { return default(TReturnType); } Above is a simple...
2
by: Max | last post by:
When you add an event handler to some object you need to specify the function to call when the event occurs. Suppose there is a class TesterClosed() which is called whenever the Tester is closed....
2
by: Nick Hajek | last post by:
I have moved a DB from 7.4.3 to 8.0.0b2 for testing and am experiencing some problems with the void type within pl functions. I am calling a function which returns a void from within another...
1
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to understand namespaces and assemblies. How are they related and what does type mean in namespaces and assemblies?
1
by: kumarkishor | last post by:
Hi Since last 1 month i have been studying asp .The question comes that what is type of server object and also the class defination of server class.
3
by: burtoncn | last post by:
Hi, Just a little background information on the project I am working on! I am responsible for creating a database to automatically generate travel claims for conference attendees (Approx. 300)...
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.