Thread: Some doubts about programming in C

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    7

    Post Some doubts about programming in C

    Firts of all, i'm from Argentina so forgve me if i makesome mistakes while writing in english...

    I'm here because in the univesity our professor gave us a project and i've got some doubts about it:

    * How do i do to read from console?
    For example, the program that i've got to make must be called from the consolo with this format:

    C:\ crcuns [-h] FILE | CRC FILE
    the brackets means that this command is optional, but if the user calles with -h I must show a little help of the program, if the introduce only the file I have to return it's CRC, and if he introduces the two fils I must compare and say if the CRC especified in the CRC File is the same as the one of the other file

    * I've got to use this "standar" libraries:
    -stdin
    -stdout
    -stderr

    but when i tried to use them from DevC++ it's tell me that they are not in my computer, that it can not find them, so i would like to know if you can help getting this libraries

    That's all for now, i've to go,

    Thanks you!
    Fran

  2. #2
    Registered User
    Join Date
    Jan 2006
    Location
    Europe/Belgrade
    Posts
    78
    You should learn basics of C then you will see functions like scanf() and printf() for I/O. Functions are declared in other files called headers. Those two functions are in stdio.h which is an ordinary file on your system (if compiler installed properly). Headers are included by your code, when you start learning, you will see how to include them.
    stdin, stdout, stderr are not standard libraries.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    903
    I'm a C++ programmer but if I recall what you have to do is something like this:
    Code:
    fprintf(STDOUT, "whatever");
    fprintf(STDERR, "error");
    fscanf(STDIN, &some_variable);

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    151
    Quote Originally Posted by Olimpo
    For example, the program that i've got to make must be called from the consolo with this format:

    C:\ crcuns [-h] FILE | CRC FILE
    http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.

    Useful resources:
    comp.lang.c FAQ | C++ FQA Lite

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by Olimpo
    Firts of all, i'm from Argentina so forgve me if i makesome mistakes while writing in english...

    I'm here because in the univesity our professor gave us a project and i've got some doubts about it:

    * How do i do to read from console?
    For example, the program that i've got to make must be called from the consolo with this format:

    C:\ crcuns [-h] FILE | CRC FILE
    the brackets means that this command is optional, but if the user calles with -h I must show a little help of the program, if the introduce only the file I have to return it's CRC, and if he introduces the two fils I must compare and say if the CRC especified in the CRC File is the same as the one of the other file

    * I've got to use this "standar" libraries:
    -stdin
    -stdout
    -stderr

    but when i tried to use them from DevC++ it's tell me that they are not in my computer, that it can not find them, so i would like to know if you can help getting this libraries

    That's all for now, i've to go,

    Thanks you!
    Fran
    stdin, stdout, and stderr, are not libraries. They are standard streams that EVERY program, by default, will have open. Stdin is your keyboard (unless it's been directed to another location), stdout is your monitor (unless it's been directed elsewhere), and stderr is by default, directed to your monitor.

    stdio.h is a header file, (like a library file), but don't confuse it with stdin, stdout, or stderr - these last three are just streams which all programs are given, by default. You don't need to do anything to get them special - they'll be there in your program, when it's able to runl.

    Calling your program with various parameters is not a problem. C language handles that nicely.

    Do you have your code to handle the CRC and file comparison functions, already done?
    Others may differ, but I would do those functions first, and have them exactly right. The parameters for your program's main function, will then just require a little tweaking.

    Your english is a LOT better than my spanish.

    Post up where you are in your programming this, and exactly what your problems are, OK? If you need to post up some code be SURE to wrap it with code tags:

    Code:
     
       /* CRC.c .... */
       <all your code goes here, between the code tags>
    Adak

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    151
    Would you mind telling us the nature of the course you're taking? I find it very bizarre that the professor would dump a project on someone without teaching things as fundamental as the command-line and the standard I/O streams.
    System: Debian Sid and FreeBSD 7.0. Both with GCC 4.3.

    Useful resources:
    comp.lang.c FAQ | C++ FQA Lite

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    7
    I'm studing "Licenciatura en Ciencias de la Computación" that is similar to a "Software Engineeer"

    the problem is that in the theory we are seeing differents bases (binary, octal, hexa) and reprsetation (sign-magnitude, complements (to the base, the the base-1)) and now we are seen float point and the norm IEEE 754 for their representation
    but in the practice, we are also using C for somo simple excercises, but in the project they gave us to implemente a CRC check (we haven't seen them in any other subject of the career and nobody undestood the explicacion that the professor gave) using all pointer (references to the type and some instructions, but we didn't have a especial class for C, we must investigate all for ourselves..
    excuse if i have asked "obvious" or, why not?, "stupid" things), it's just that i do not know where to go...

    thanked you for all you asks... i'll work on the project and if something comes up i will tell you

    see ya!
    thanks
    fran

  8. #8
    Registered User
    Join Date
    Jan 2006
    Location
    Europe/Belgrade
    Posts
    78
    If you need C, get a book, because it will guide you step by step.

  9. #9
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Or read the tutorials on this very site...
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doubts regarding random numbers generation
    By girish1026 in forum C Programming
    Replies: 9
    Last Post: 12-31-2008, 10:47 PM
  2. More questions (relating to global doubts)
    By Jorl17 in forum C++ Programming
    Replies: 29
    Last Post: 12-03-2008, 11:40 AM
  3. Some doubts on DLLs
    By BrownB in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2007, 02:25 AM
  4. Two doubts about C for my project
    By j0nnyX in forum C Programming
    Replies: 4
    Last Post: 10-11-2004, 02:31 PM
  5. doubts on scanf
    By aqua in forum C Programming
    Replies: 1
    Last Post: 10-28-2002, 04:20 AM