Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

va_list concept

  • Loading branch information...
commit 13b2e48f90851870869d4aa8e6f76b8a410ed4f8 1 parent 45b5d53
Rajeev N Bharshetty authored
Showing with 40 additions and 0 deletions.
  1. +40 −0 variand.c
40 variand.c
View
@@ -0,0 +1,40 @@
+/*
+ * =====================================================================================
+ *
+ * Filename: variand.c
+ *
+ * Description: Implementation of va_list datatype
+ *
+ * Version: 1.0
+ * Created: Saturday 31 December 2011 01:31:18 IST
+ * Revision: none
+ * Compiler: gcc
+ *
+ * Author: Rajeev N B<coder.rshetty@gmail.com>
+ * Company: RVCE
+ *
+ * =====================================================================================
+ */
+
+#include<stdio.h>
+#include<stdarg.h>
+void someDemoArgs(int mt,...)
+{
+ va_list var; // Data type of the variable arguments
+ int i;
+
+ va_start(var,mt); //va_start(va_list variable,last argument in the function)
+ for (i = mt;i>=0; i = va_arg(var,int)) //va_arg(va_list varibale,data type of the next argument) returns the next argument
+ {
+ printf("%d\n",i);
+ }
+ va_end(var);
+ putchar('\n');
+
+}
+
+int main(void)
+{
+someDemoArgs(10,20,30,40,69,-1); // Sentinal Value -1 is a must as a last argument
+return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.