Page 8 of 9 FirstFirst ... 56789 LastLast
Results 71 to 80 of 82
  1. #71

    Quote Originally Posted by drixx101 View Post
    try daw before every scanf add ug flushall();
    fflush(stdin) is definitely bad - it is UNDEFINED. Imagine a small embedded system where memory is tight. To conserve memory, an input only file is shortened, because it doesn't need the output buffer that the output files have [and this is the BIG part of the structure behind a FILE pointer]. When you call fflush() on an input only file, it will attempt to access the data in the output section of the data structure - which isn't there. The consequence of this may be that the system crashes, or that some random data is output to some random file/console location. Not a particularly good thing.

    The function "flushall()" is just a loop doing "fflush()" on every file in the system, which of course means that stdin will be flushed, along with any other input and output files that are currently open. Not a particularly good idea.

    --Source
    Quote Originally Posted by drixx101 View Post
    also ayaw nlng himo ug functions for add, subtract, multiply and divide, dretsoa nlng..the shorter the code the better,,
    Quote Originally Posted by marcdaven View Post
    "create a pseudocode, flowchart and c program that ask the user 2 integer numbers. The user then enters another character in order to choose which operator to perform: A - addition, s - subtraction, m - multiplication, d- division. create separate functions for each operation."
    Quote Originally Posted by drixx101 View Post
    ..and para maresolve n inyo conflict sa void main(void), mao na xa ang declaration because ang main function does not return anything, and wala pud ipass nga parameters sa main, that's why void main(void).. Pwede man pud nang int main(void), pero magbutang ka ug return 0; sa end sa main function, w/c is dugang npd sa code confusion..
    Declaring main() as void is kind of like saying ``ain't''. Everyone will know what you mean, but it's not ``correct english'', and people who care about correct english will think less of you for saying it.

    Suffice it to say that, just because void main() works for you, doesn't mean it's right. If you run a red light in the middle of the night and no policeman arrests you, does that mean it's okay to run red lights? If you have the ball in a basketball game and you take three steps without dribbling and the ref doesn't notice, does that mean that traveling is legal in basketball?

    --Source
    Quotes, quotes, and more quotes.
    Last edited by doomsweek; 02-13-2010 at 09:41 AM.

  2. #72
    scanf("%s", &c);

  3. #73
    Quote Originally Posted by xxharz View Post
    scanf("%s", &c);
    Bro, unsa nang %s nga string? Bag-ohan ko ani dah

  4. #74
    Quote Originally Posted by xxharz View Post
    scanf("%s", &c);
    Buffer Overflow potential?

    Quote Originally Posted by marcdaven View Post
    Bro, unsa nang %s nga string? Bag-ohan ko ani dah
    %s means that scanf will be waiting for a string input from the user and store it to the address pointed by c.

  5. #75
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    you can use scanf(“%255s”, buffer) to prevent overflow. however, using %s for datatype "char" is illegal! unless it is an array of characters and take note that C don't have "string" data type only C++.

  6. #76
    Quote Originally Posted by MarkCuering View Post
    however, using %s for datatype "char" is illegal!
    Hala oi, nagnosebleed nako sa mga words ninyo! Wa jud ko naka sabot unsa meaning anang "buffer"... T_T Anyways, this thread doesn't need to be lengthen anymore. I hope any moderator will lock this soon.

    Thanks sa mga tabang ninyo mga bro!

  7. #77
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    its just a variable...no big deal

    FILES=30
    STACKS=0,0
    BUFFERS=20000000000000000000


    hehehehe

  8. #78
    Quote Originally Posted by ChaosOrb View Post
    getch() - get character without echo
    getche() - get character with echo
    kani mao na ang difference sa duha.... 'echo' means mogawas sa display/monitor ang imong gipress sa kibord.... so it is best to use "getche" for making choices.

    kaning int main (void), ayaw na gamita kay mao ra gihapon dili ninyo gamiton nang 'int' nga word before sa main. so instead nga 'int', gamit nalang og 'void main (void)'.. meaning dili xa mo-return og values, og dili pud xa mo accept og values.
    sample sa 'mo-accept og values': void main (int a)
    void main (int a, int b){
    clrscr();
    printf ("the sum of %d and %d is %d",a,b,(a+b));
    getch();
    }
    so para mogana nang 'int a, int a' sa main(), dapat imo xang tagaan og parameters before nimo xa erun, mao ni ang isa sa paagi (compute.exe ang name sa program):
    c:\compute.exe 1 2
    so inig press nimog enter ana, mo-automatic nana xag compute sa 1 og 2...

    so, kay dili man ingun-ana ang style sa imong program, best jud nga mogamit kay 'void main (void)'



    ...aw tama ba? ^_^ ... kalimot na man gud ko ani... hehehe
    Last edited by hizuka007; 02-18-2010 at 08:02 PM.

  9. #79
    Quote Originally Posted by hizuka007 View Post
    kaning int main (void), ayaw na gamita kay mao ra gihapon dili ninyo gamiton nang 'int' nga word before sa main. so instead nga 'int', gamit nalang og 'void main (void)'
    Wrong.

    The value returned from the main function becomes the exit status of the process, though the C standard only ascribes specific meaning to two values: EXIT_SUCCESS (traditionally zero) and EXIT_FAILURE. The meaning of other possible return values is implementation-defined.
    The return type of main() must always be an int, this allows a return code to be passed to the invoker.
    What's the deal with void main()

    Under regular function calling/returning in C and C++, if your don't ever want to return anything from a function, you define it's return type as void. For example, a function that takes no arguments, and returns nothing can be prototyped as:

    void foo(void);

    A common misconception is that the same logic can be applied to main(). Well, it can't, main() is special, you should always follow the standard and define the return type as int. There are some exceptions where void main() is allowed, but these are on specialised systems only. If you're not sure if you're using one of these specialised systems or not, then the answer is simply no, you're not. If you were, you'd know it.

    Be warned that if you post your "void main" code on the forums, you're going to get told to correct it. Responding with "my teacher said it's OK" is no defence; teachers have a bad habit of being wrong. Be safe, and post only standard code, and you'll find people concentrate on answering your other problems, rather than waste time telling you about this type of thing.
    Quote Originally Posted by hizuka007 View Post
    sample sa 'mo-accept og values': void main (int a)
    Wrong. It is:
    Code:
    int main(int argc, char *argv[])
    The parameters argc, argument count, and argv, argument vector, respectively give the number and value of the program's command-line arguments.
    Sources:
    [1]
    [2]
    Last edited by doomsweek; 02-18-2010 at 09:43 PM.

  10. #80
    hinnnnnnnndiiiiiiiiiiiii!! bagsak na diay ko aning programming.. ....

    btw, wa pud diay to kabalo among teacher bahin aning int main() og void main() ..

  11.    Advertisement

Page 8 of 9 FirstFirst ... 56789 LastLast

Similar Threads

 
  1. Help me in my laptop problem
    By Wenxp7 in forum Computer Hardware
    Replies: 16
    Last Post: 10-08-2010, 07:48 PM
  2. pls help me in my pldt dsl connection...
    By glenntacan in forum Networking & Internet
    Replies: 5
    Last Post: 01-23-2009, 05:15 PM
  3. help me in my front panel config
    By absimon in forum Computer Hardware
    Replies: 5
    Last Post: 12-05-2008, 07:18 PM
  4. Please help me in martial arts.
    By Chalil in forum Sports & Recreation
    Replies: 11
    Last Post: 09-20-2006, 10:52 PM
  5. Where can I repair my flash drive?!!! Help me!!!
    By jonmlas in forum Gizmos & Gadgets (Old)
    Replies: 13
    Last Post: 11-30-2005, 12:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top