Second program

This is a discussion on Second program within the C Programming forums, part of the General Programming Boards category; Hi again, i started programming c like 8 hours ago and i'm going to take a break when this program ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    49

    Talking Second program

    Hi again, i started programming c like 8 hours ago and i'm going to take a break when this program is working
    I know there are probably heaps better ways of doing this i just wanted to see if i could write a function on my own without notes but it doesnt look like i can yet.

    Code:
    #include <stdio.h>
    #include <strcmp.h>
    
    main()
    {
    	
    	char c;
    	char d;
    	printf("Hi, I am the name genie and i am good at addition\nWhat would you like to do?\nPress A to subtract or B to get insight into your name");
    	scanf("%s",c)
    		if(!strcmp(c,a))subb;
    		else nam;
    		return 0;
    }
    
    subb()
    int r;
    int t;
    int q;
    {
         printf("Please enter a number the press enter : ");
    	 scanf("%d",&r);
    	 printf("What would you like me to add to that number? : ");
    	 scanf("%d",&t);
         q=r+t;
    	 printf("%d plus %d equals %d",r,t,q);
    	 return 0;
    }
    
    nam()
    char x[20];
    char kate[9];
    {
    	printf("Please enter your name : ");
    	scanf("%s",x);
    	if(!strcmp(x,kate))
    		printf("Thats a great name!!!!");
    	else printf("Ha, what a crap name!!!");
    	return 0;
    }
    i get these errors

    c:\program files\microsoft visual studio\vc98\include\stdio.h(1) : warning C4182: #include nesting level is 363 deep; possible infinite recursion
    c:\program files\microsoft visual studio\vc98\include\stdio.h(1) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit

    is this the right kind of layout for a program?

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    49
    the books called sams teach yourself c in 21 days
    know of any recent tutorial sites?
    cool avatar by the way

  3. #3
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    and you most let the compiler know of your funktions befour you call them.
    Like this:

    Code:
    #include <stdio.h>
    */more includes goes here*/
    
    void subb ();
    void nam ();*/cant see a reason for these to return a value else you can make them int or doulbe for example*/
    and you should also say the
    Code:
    void subb (){
    when you write the funktion.

    :edited for gramma and spelling mistakes:
    Last edited by Shogun; 07-25-2003 at 09:45 AM.
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    49
    woops about the <string.h> thing, ididnt even notice it
    same compile errors though

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    49
    hmmm, i forgot them damn prototypes awell
    thanks
    but still same errors

  6. #6
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    you should also use int main (void)
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  7. #7
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    Originally posted by Elite
    the books called sams teach yourself c in 21 days
    know of any recent tutorial sites?
    cool avatar by the way
    http://www.google.com/search?hl=sv&i...torials%22&lr=
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  8. #8
    Registered User
    Join Date
    Jul 2003
    Posts
    49
    lol
    thats how i found the sams book

  9. #9
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    Elite,
    can you give me the adress of that book?
    Loading.....
    ( Trying to be a good C Programmer )

  10. #10
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  11. #11
    Registered User
    Join Date
    Jul 2003
    Posts
    61
    Originally posted by Elite
    the books called sams teach yourself c in 21 days
    know of any recent tutorial sites?
    cool avatar by the way
    http://www.eskimo.com/~scs/cclass
    http://www.geocities.com/tom_torfs/cintro.html
    $ENV: FreeBSD, gcc, emacs

  12. #12
    Registered User
    Join Date
    Jul 2003
    Posts
    49
    cool
    thanks guys
    anyone have an idea whats wrong with the program?

  13. #13
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    if you have changed everything like was said I think it should work.
    (if it doesn't don't shoot me I'm no expert just someone playing with this on his sparetime)
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  14. #14
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    oh and what are you using the d variable in the main funktion for?
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  15. #15
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    Ok, thanks for the link.
    About the program, one of the mistakes is:
    >scanf("%s",c)
    c is defined to be a character, so it shold be
    scanf( "%c", &c )
    or if you wanted to input a strind you should declare c as an array of characters.

    I haven't seen all your program, just my eye fell on this part.
    Loading.....
    ( Trying to be a good C Programmer )

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21