Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 468 Bytes

CppHelloNagC.md

File metadata and controls

25 lines (22 loc) · 468 Bytes

Hello NAG using C is a Hello World program to test the NAG library.

#include <math.h>
#include <nag.h>
#include <nag_stdlib.h>

int main(void)
{
  char * s = 0;
  s = NAG_ALLOC(11,char);
  if (!s)
  {
    printf("Cannot allocate memory for s");
    return 1;
  }
  sprintf(s, "Hello NAG");
  puts(s);
  NAG_FREE(s);
  return 0;
}