Search:

Type: Posts; User: Brain_Child

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    7
    Views
    4,107

    one thing that looks troublesome is this ...

    one thing that looks troublesome is this


    student_t *myStudents[10];

    to me, you have declared a 2d array. but then you write this


    strcpy(course_t.myStudents[0].fname, "Bob");
  2. Replies
    11
    Views
    10,410

    well if you need another clue, I wrote this...

    well if you need another clue, I wrote this program to help me determine the relationship


    #include <stdio.h>

    int main (void)
    {
    int array[3][4];

    int i, k, j=0;
  3. Replies
    11
    Views
    10,410

    oh ok. is this a common programming practice...

    oh ok.

    is this a common programming practice though?

    i ask cause couple weeks ago I had to code up a BFS type algorithm on a grid represented as a string, and not a 2d array. it was painful...
  4. Replies
    13
    Views
    25,613

    the purpose of programming assignments is to give...

    the purpose of programming assignments is to give you a chance to learn the language through practice. your lecturer/tutor doesnt want a correct program for the sake of it. if they really wanted it...
  5. Replies
    11
    Views
    10,410

    im confused. how could you possibly get that...

    im confused. how could you possibly get that output if you declare but dont initialise
  6. Replies
    2
    Views
    1,613

    here is the key line while (getchar() !=...

    here is the key line



    while (getchar() != EOF)


    what this means is the while loop (which just increments the counter by one) will continue as long as you do not enter the EOF character.
    ...
  7. Replies
    16
    Views
    2,647

    ah yes, only 19. the 20th spot is reserved for...

    ah yes, only 19. the 20th spot is reserved for the null byte
  8. Replies
    16
    Views
    2,647

    fgets is what you should use char *fgets(char...

    fgets is what you should use

    char *fgets(char *s, int size, FILE *stream);

    eg


    fgets(name, 20, stdin);
  9. here is the fix. int ch; ... ...

    here is the fix.


    int ch;

    ...

    printf("No. Try Again. What is %d / %d = ? ", first, second);
    while ((ch = getchar()) != '\n' && ch != EOF);...
  10. Replies
    2
    Views
    22,002

    firstly, you need to get the numbers from the...

    firstly, you need to get the numbers from the user with something like


    scanf("%d", &number);

    secondly, your for loop doesnt do quite what you expect it to do


    for (number1 = 1 ;...
  11. you shouldnt try to work out this problem because...

    you shouldnt try to work out this problem because your code is just poor and you should never have anything at all resembling that line in a real program.

    why?

    for the very reason that you are...
  12. Replies
    20
    Views
    21,635

    cant use fflush to clear the input buffer ...

    cant use fflush to clear the input buffer

    Cprogramming.com FAQ > Why fflush(stdin) is wrong



    see here

    Cprogramming.com FAQ > Flush the input buffer
  13. Replies
    4
    Views
    1,596

    typedef struct { char firstName[30];...

    typedef struct {
    char firstName[30];
    char lastName[30];
    char street[35];
    char city[20];
    char state[3];
    int zip;
    ...
  14. I've written some complicated code and I am in no...

    I've written some complicated code and I am in no way measuring the quality of this program by line count.

    I just dont understand why 3 extra variables have to be created (I also dont understand...
  15. I agree. im also confused as to why you have...

    I agree.

    im also confused as to why you have variable names x,y,z and e. to me that means the e is special, significant in some way.

    also, why do you have 3 lines of arithmetic? as opposed to...
  16. Replies
    14
    Views
    3,490

    you have your printf("a\b...}"); in the middle of...

    you have your printf("a\b...}"); in the middle of a for loop. so everytime you find a matching pair you are printing the entire line. you need to take it out of the for loop and print it only once....
  17. Replies
    21
    Views
    7,482

    it is true that you can use loops and recursion...

    it is true that you can use loops and recursion to write this program, but the first step is to understand what you are trying to do and solve the problem, and then turn that solution a C program.
    ...
  18. Replies
    6
    Views
    3,724

    this works. ive bolded the changes despite...

    this works.

    ive bolded the changes

    despite its name, getchar works with integers, not chars. I think this program will still work if you have char repeat, but it should be an integer. I believe...
  19. Replies
    5
    Views
    7,477

    I think you want guess [0] == guess[1] to be...

    I think you want

    guess [0] == guess[1]
    to be true. but you also want


    guess [0] ==guess [2]

    to be true at the same time
  20. Replies
    21
    Views
    7,482

    lets start from the beginning 1) do you know...

    lets start from the beginning

    1) do you know what a binomial coefficient is?
    2) do you know the formula for the binomial coefficient?
  21. Replies
    26
    Views
    2,693

    be sure that you understand your problems the...

    be sure that you understand your problems

    the point of small programming exercises isnt to finish, its to help you learn the language. if you write 10 programs, but are still making the same...
  22. Replies
    10
    Views
    4,010

    I think you should begin by first writing each of...

    I think you should begin by first writing each of the functions in the header file, dont worry about the main for now.

    you might also like to write a test function so that you know your functions...
  23. Replies
    13
    Views
    2,695

    while (scanf("%d%d",&n,&k)==2) { goes...

    while (scanf("%d%d",&n,&k)==2)
    {


    goes to


    while (scanf("%d%d",&n,&k)==2) {
  24. Replies
    2
    Views
    1,615

    strcat adds on the second string to the end first...

    strcat adds on the second string to the end first string. so you have to leave some space at the end of the first string. for example



    char date1[20]="Dec 29, 8:30";
    char date2[20]="Dec...
  25. Replies
    2
    Views
    860

    char array[] = "Sep 29, 19:34"; ...

    char array[] = "Sep 29, 19:34";
    printf("length of string is %d\n", strlen(array));


    that code will definitely produce a result of 13

    what does your code look like? particularly the line...
Results 1 to 25 of 35
Page 1 of 2 1 2