Jump to content
Heads Up! This website is no longer maintained, if your a member from our era, consider joining the discord to say hello.
Sign in to follow this  

My Example Of Using An Array With Ansi C

Recommended Posts

/*C owns so much..........*
*Hardcore simple program created by AgentGOD, in C*
*This will demonstrate how much better using the ANSI C headers*/

#include <stdio.h> // :) Just to show off different ways to comment code
/* Here of course, we have the standard input output for ANSI C */
const int ArraySize = 50;
/*This here defines a constant containing the total array size*
*of course there are ways to create dynamically adjustable arrays...*
*but I won't get into that now, i want to keep things simple.*/

int main()
{
  char fname[255]; //"String" variable, really its just a char array with 255 spaces allocated
  int Numbers[ArraySize], inNumber, Count = 0; //Int variables
  printf("Please type your first name: "); //prompter;)
  scanf("%s", &fname); //uses scanf to store your name
  printf("Your first name is %s\n", fname);
  printf("Enter an integer (enter -999 to quit): ");
  scanf("%d", &inNumber);
  while((inNumber != -999) && (Count < 50)) //conditional while loop
  {
  Numbers[Count] = inNumber;
  printf("Enter another integer (enter -999 to quit): ");
  scanf("%d", &inNumber);
  ++Count;
  }
  printf("You have entered the following integers: \n");
  for(int x = 0; Numbers[x] != -858993460; ++x)
  printf("%d\n", Numbers[x]);
  return 0;
} 

 

Here you go my newbs...

 

*HYPNOTIK*I COMMAND YOU TO LEARN..... LEARRRNN..... LEEAAARRRRNNN!!!!*/*

Share this post


Link to post
Guest Lord-Bren

*Pinned* Vary usefull

Share this post


Link to post

eh? so what language are you writing in x_x why is programming so difficult x_x

elwell thanks for sharing i guess.

Share this post


Link to post

Dude this was posted in 2006 please look at the dates before posting.

Share this post


Link to post
Dude this was posted in 2006 please look at the dates before posting.

 

Yeah, but while were on the topic, i'd like to point out the difficulty. Programming in C++ isn't daunting if you thoroughly study the keys and strings. I'm currently reading a book explaining C++ and its easy. ^_^

Share this post


Link to post

True C++ is easy but only if you can do the math.

Share this post


Link to post
True C++ is easy but only if you can do the math.

 

I can do the math, cause I kick ass

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×