Search:

Type: Posts; User: cnewbie1

Page 1 of 5 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    1,284

    Not sure what you mean? Do you mean how to...

    Not sure what you mean? Do you mean how to calculate the average? Then the answer is to add up all numbers and devide it by the number of numbers. F.ex.: The average og 4,5,6 = (4+5+6)/3.

    Other...
  2. Replies
    5
    Views
    1,086

    Elysia: That was going to be my follow-up...

    Elysia: That was going to be my follow-up question. I know that it's possible, but I wondered if it would be a more "tidy" way of doing it. In the example I was playing with, where the values needs...
  3. Replies
    5
    Views
    1,086

    Thanks - good answer :-)

    Thanks - good answer :-)
  4. Replies
    5
    Views
    1,086

    Variable initialization

    One of the reasons I allmost never get any real work done, I think, is that I allmost allways stumble over small things that I don't understand. And then, instead of pragmatically solving it another...
  5. Replies
    27
    Views
    2,547

    Would this be a valid way of doing it, then? ...

    Would this be a valid way of doing it, then?


    int main (int argc, char *argv[]) {
    char buf[25];
    if (!func(buf)) {
    printf("Oh crap, that didn't work!\n\n");
    return 0;
    }
  6. Replies
    27
    Views
    2,547

    Of course. Impresise wording on my part. ...

    Of course. Impresise wording on my part.

    However, I still don't see the point of using the extra pointer when you can just pass buff[] to the function. As per the examples above like this:

    ...
  7. Replies
    27
    Views
    2,547

    Hm, ok. I think I understand. You could f.ex....

    Hm, ok. I think I understand. You could f.ex. return the pointer to an array, and in the calling code use that to check wether or not the function did it's job; if the returned pointer is null, then...
  8. Replies
    27
    Views
    2,547

    Ok, about what I thought. But is there a reason...

    Ok, about what I thought. But is there a reason for using f.ex. a *char function which returns nothing, or could it just as well be a void function?
  9. Replies
    27
    Views
    2,547

    Arrays and functions (again)

    I read a (seemingly good) tutorial on how to "return arrays from functions". This is one of the methods described: "Have the caller allocate an array and use that within the function":


    char...
  10. Replies
    6
    Views
    2,367

    Logical, of course.

    Logical, of course.
  11. Replies
    6
    Views
    2,367

    So how can I get the size of an array created by...

    So how can I get the size of an array created by using malloc()?
  12. Replies
    6
    Views
    2,367

    (char) array initialization, size etc.

    1:
    char parray[10];
    strcpy(parray, "abcdefghij");
    printf("%s, %lu\n", parray, sizeof(parray)/sizeof(char));

    2:
    char *marray = malloc(10*sizeof(char));
    strcpy (marray, "abcdefghij");...
  13. Replies
    29
    Views
    9,034

    Ah, of course. Should've read the specification...

    Ah, of course. Should've read the specification more closely. Frightningly simple. Thanks.
  14. Replies
    29
    Views
    9,034

    I'm running this string through strtok(): ...

    I'm running this string through strtok():

    00:name:2:morename:2204a3741a4f4c636acb71cca5da1b0041446e554d9fb1a2dceec29428491a17



    - calling function - reads the above line from a text file and...
  15. Replies
    29
    Views
    9,034

    Yah, of course you're right. And I've looked at...

    Yah, of course you're right. And I've looked at strtok. The problems remain, however, as strtok just gets the substrings. I can do that manually as well. But:

    1. How to resize a char array of size...
  16. Replies
    29
    Views
    9,034

    Fordi: Thanks, but C != C++ ssharinsh:...

    Fordi: Thanks, but C != C++

    ssharinsh: Hmm....exactly what does that do?
  17. Replies
    29
    Views
    9,034

    char arrays, "cutting", resizing etc.

    I'm doing this (quite simple) operation:

    - Read a line from a semi-colon-separate file:

    00:name:22:name2:blablablablablahblahblah

    This string has a length of 104, allowing for the these...
  18. Replies
    18
    Views
    3,511

    ssharish2005: You're getting and error using the...

    ssharish2005: You're getting and error using the code I pasted? Exactly what are you doing?
  19. Replies
    18
    Views
    3,511

    I thought so too. Also, why should it be...

    I thought so too. Also, why should it be necessary to return anything from that function? The array is created in the calling function, and the populate() function populates the array using the...
  20. Replies
    18
    Views
    3,511

    Ah, thanks - think I got it now: char...

    Ah, thanks - think I got it now:


    char *populate (char (*)[64]);

    int main (int argc, char *argv[]) {
    char str[5][64];

    populate(str);
    puts(str[0]);
  21. Replies
    18
    Views
    3,511

    The strcpy name is only because I forgot to...

    The strcpy name is only because I forgot to change the name from the previous example I worked on. The thing I'm trying to find out is how to do the same as this with a 2-d array:



    char...
  22. Replies
    18
    Views
    3,511

    Hm...do I need to redefine the my_strcpy()...

    Hm...do I need to redefine the my_strcpy() function? If I remove everything inside the function:


    char *my_strcpy (char *);

    int main (int argc, char *argv[]) {
    char str[5][64];
    ...
  23. Replies
    18
    Views
    3,511

    Char arrays and functions

    I know I should read more, and I am, but sometimes it helps to get clear example answers to my more or less clear example questions. So, here goes:

    This works:


    char *my_strcpy (char *);
    ...
  24. I know that indexes start at zero, of course. ...

    I know that indexes start at zero, of course.

    Ah, dagn - I get it.


    int table[2][3] = { {0,0,0},{1,1,1} };
    000 is row one, 111 is row two, of course.

    Thanks :-)
  25. Idiot question about multidimensional arrays

    Definition of two-dimensional array:

    data_type array_name[row_size][column_size];

    This:

    int table[2][3] = { {0,0,0},{1,1,1} };

    works. Why? This should mean a size 2 row and a size 3...
Results 1 to 25 of 115
Page 1 of 5 1 2 3 4