Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 41

Thread: help needed to understand c

  1. #11
    Join Date
    Sep 2003
    Posts
    2,849
    Rep Power
    0

    Default Re: help needed to understand c

    what about strings? ive heard people refer to strings as a type of array.
    eg array[]="abc";
    array[]="a", "b", "c";
    starry heavens above and the moral law within
    Open source!
    dmitridawkins.com

  2. #12
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re: help needed to understand c

    Quote Originally Posted by megiddo
    what about strings? ive heard people refer to strings as a type of array.
    eg array[]="abc";
    array[]="a", "b", "c";
    a string logically is a collection of letters. so basically anything that is a collection of stuff can be refered to as an array. it doesn't mean that it is literatlly an "Array" but figuratively behaves like one.

    confusion sponsered by owensoft

  3. #13
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: help needed to understand c

    how do u use the gets n puts func to replace... printf an scanf

  4. #14
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re: help needed to understand c

    gets and puts - as in when writing to files?

  5. #15
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: help needed to understand c

    accepting input from a user... and outputing... i suppose to write a program without using printf or scanf... i heard the alternative is puts n gets... it nuh really mek much sense to me

  6. #16
    Join Date
    Oct 2004
    Posts
    4,814
    Rep Power
    24

    Default Re: help needed to understand c

    Here is a simple example:
    Code:
    #include <stdio.h>
    
    
    int main() {
    
    	char name[256];
    
    	puts("please enter your name: ");
    	gets(name);
    
    	puts("your name is: ");
    	puts(name);
    }

  7. #17
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re: help needed to understand c

    do you understand printf or scanf? why not use those?

    or try what leoandru said

  8. #18
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: help needed to understand c

    Quote Originally Posted by owen
    do you understand printf or scanf? why not use those?

    or try what leoandru said
    I understand how to use them but ma lecturer was saying that puts n gets are more efficient and that we need to eliminate using the scanf or printf when coding... he said that um... when u enter n e thing other than an int usin scanf the prg will crash and our programs should be crash free...


    the assignment i have to do is to develop a paymaster kinda system... givin penalties for overdue bills n blah blah

  9. #19
    Join Date
    Feb 2005
    Posts
    418
    Rep Power
    0

    Default Re: help needed to understand c

    Quote Originally Posted by leoandru
    Here is a simple example:
    Code:
    #include <stdio.h>
    
    
    int main() {
    
    	char name[256];
    
    	puts("please enter your name: ");
    	gets(name);
    
    	puts("your name is: ");
    	puts(name);
    }



    Oh zeen... hmm thanks

  10. #20
    Join Date
    Oct 2004
    Posts
    4,814
    Rep Power
    24

    Default Re: help needed to understand c

    Quote Originally Posted by Liquid Bunny
    I understand how to use them but ma lecturer was saying that puts n gets are more efficient and that we need to eliminate using the scanf or printf when coding... he said that um... when u enter n e thing other than an int usin scanf the prg will crash and our programs should be crash free...


    the assignment i have to do is to develop a paymaster kinda system... givin penalties for overdue bills n blah blah
    yeah he is right about gets, it is more efficient when reading input but i can't say the same for printf vs puts, it's neither here nor there. However i know what kinda problems you may get into when trying to read intergers when using scanf, gets is jus one of the methods around that. If you going to use gets to read interger inputs then you will need to convert that string into an integer, but I know you are going to figure that one out .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •