Is anyone kind enough to teach me a little C-programming?

  • Welcome to the Devil May Cry Community Forum!

    We're a group of fans who are passionate about the Devil May Cry series and video gaming.

    Register Log in

CheeseKao

Lord Cheesington
Jan 19, 2012
1,142
706
1,165
I'm trying to split a number with n digits into n numbers and add them up. For example: I type in 29 and I need a method to get the sum of 2 and 9.

#include <stdio.h>
int main(int argc, char *argv[])
{
int year[3],S4;
printf("Enter your year of birth: ");
scanf("%d", year);
S4=year[0];
printf("%d", S4);

return 0;
}

I tried doing this but when I type a number like 1990, it outputs 1990 instead of 1. Do note that I am a beginner and I don't really know any advanced functions and such. Any help is very much appreciated.
 
I could probably have told you in 2006, when I was doing this in uni, but I've forgotten completely. Wow. Like, complete brain wipe. I recognize it all, but I've lost my definitions. And I don't have my killer book of C programming anymore, or Borland to test it. (I just looked)

Sorry.