July 2013 | C Programming and Computer Geeks

Search MY Blog

Sunday 14 July 2013

Arrays & Dynamic Memory Allocation - Basic Faq

1.How can I set an array's size at run time?  How can I avoid fixed-sized arrays?
ANS: The equivalence between arrays and pointers allows a pointer to malloc'ed memory to simulate an array quite effectively. After executing
               #include <stdlib.h>
               int *dynarry;
               dynarry = malloc(10 * sizeof(int));
(and if the call to malloc succeeds), you can reference dynarry[i] (for i from 0 to 9) almost as if dynarry were a conventional, statically-allocated array (int a[10]). The only difference is that sizeof will not give the size of the ``.

Friday 5 July 2013

C Faq - Part 3

1. What will be output if you will compile and execute the following c code?
#include<stdio.h>
int main(void)
{
  int a=5;
  float b;
  printf("%d",sizeof(++a+b));
  printf(" %d",a);
  return 0;
}


Tuesday 2 July 2013

C Basic Faq


1. What is C language??
The C programing language is a standardized programing language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages. C is prized for its efficiency, and is the most popular programing language for writing system software, though it is also used for writing applications.

Search This Blog