Search⌘ K

Example 99: Function with a Variable Number of Arguments

Explore how to write a function in C that accepts a variable number of arguments representing point coordinates, and identify the shape they form. Understand the use of stdarg.h macros to iterate through the arguments, enabling flexible function designs based on differing input lengths.

We'll cover the following...

Problem

Write a function that receives a variable number of arguments, where the arguments are the coordinates of the point. Based on the number of arguments received, the function should display the type of shape (for example, a point, line, triangle, etc.) drawn from them.

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can ...