Search:

Type: Posts; User: waxydock

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    4,489

    but i did.. ive got the following includes ...

    but i did.. ive got the following includes

    #include <mpi.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
  2. Replies
    4
    Views
    4,489

    snprintf warning error

    Hi,

    im getting the following warning during compiling. gol.c:568: warning: implicit declaration of function `snprintf'.

    snprintf is probably not apart of standard C and since I was told to use...
  3. Thread: String copy

    by waxydock
    Replies
    2
    Views
    1,697

    String copy

    Hi,

    Is it ok to make a copy of my string like this?

    char *s1 = malloc(sizeof(char)*6);
    char *s2 = malloc(sizeof(char)*6);

    /* do some processing on s1 */

    s2 = s1;
  4. Replies
    13
    Views
    22,657

    Thanks MacGyver, nvoigt this solution works...

    Thanks MacGyver, nvoigt this solution works great!.. thanks

    counter = counter + snprintf(myarray+counter,sizeof(char)*1000,"%d",run);
  5. Replies
    13
    Views
    22,657

    I see, so what ever i added to the array before...

    I see, so what ever i added to the array before the int will be overwritten??
    ie. if i did myarray[0]='a'; before the snprintf.. it would no longer be in the array? if so.. how can i avoid this.
  6. Replies
    13
    Views
    22,657

    ok, i understand what you are saying now, but i...

    ok, i understand what you are saying now, but i have a problem.

    Currently i am adding char's to my char* array like normal and am keeping a counter to the current element im at. So for example:
    ...
  7. Replies
    13
    Views
    22,657

    ok.. after this char szBuffer[BUFSIZ];...

    ok..

    after this

    char szBuffer[BUFSIZ];
    int num = 100;

    snprintf(szBuffer,sizeof(szBuffer),"&#37;d",num);
  8. Replies
    13
    Views
    22,657

    ""Take 5 and put '5' inside for example?"" ...

    ""Take 5 and put '5' inside for example?""

    exactly
  9. Replies
    13
    Views
    22,657

    putting int in my char array

    Hi,

    I have a char array and i want to put an int inside it. I tried some thing like this but it didnt work

    int num = 2;

    char *myarray = malloc(sizeof(int)*5);

    myarray[0] = (char)num;
  10. Replies
    4
    Views
    10,952

    dynamically setting size of 2d char array

    How do i go about dynamically setting size of a 2d char array.

    is this right?

    int numcols = 2;
    int numrows = 2;

    char *my2darray = malloc(numcols*numrows); /* since size of char is 1 */
    ...
  11. Replies
    2
    Views
    5,795

    dynamic memory allocation char array

    Hi,

    Im trying to dynamically allocated the number of elements to my char array. Whats the best way to do this.. maybe something like this?

    int sizeofarray = 10;

    char *myarray =...
  12. Replies
    5
    Views
    4,116

    cheers, ill give it ago

    cheers, ill give it ago
  13. Replies
    5
    Views
    4,116

    combining digits into a number

    Hi,

    im getting digits from a file, but i need to know how to combine these digits into a number so i can store it as an int. So for example my file is

    1234

    i then read digit by digit like...
  14. Thread: MPI in C

    by waxydock
    Replies
    0
    Views
    949

    MPI in C

    I'm not sure how many ppl know about mpi, but ill ask anyway...

    Ive written a piece of code below where im receiving messages from the master processor ie. 0, and i want to stop receiving when i...
  15. Replies
    9
    Views
    1,867

    ok, i heard off a friend that there was a way to...

    ok, i heard off a friend that there was a way to avoid the recursive call by playing with the modules..

    you see all the function needs to do is return the ultimate collapse, which is just a...
  16. Replies
    9
    Views
    1,867

    make these functions more efficient

    Hi everyone,

    Is there a way i can make these functions more efficient?



    int UlitmateCollapse (int num) {

    int ones, sum = 0;
  17. Replies
    30
    Views
    3,550

    isnt that what my code is doing?? please check it...

    isnt that what my code is doing?? please check it for me and see if thats what you mean.



    #include <stdio.h>

    #define maxSize 10001

    int main (int argc , char** argv) {
  18. Replies
    30
    Views
    3,550

    then how do i get the next 1000 from the same...

    then how do i get the next 1000 from the same input

    thats what i was trying to do here



    #include <stdio.h>

    #define maxSize 10001
  19. Replies
    30
    Views
    3,550

    no.. my plan was to just get 1000 digits at a...

    no.. my plan was to just get 1000 digits at a time.. there is no need to store everything.. i just need to proccess the 1000 digits, then get the next lot of 1000 (ignoring the prev. 1000 that i had...
  20. Replies
    30
    Views
    3,550

    but you never store the million digits right? you...

    but you never store the million digits right? you just store 1000 at a time, or am i wrong?

    also can an int array hold 1000000 + digits?
  21. Replies
    30
    Views
    3,550

    This is the sudo code they gave in the...

    This is the sudo code they gave in the question...



    let the length of a buffer = x

    read digits as many as x from standard input

    while ( the buffer contains some digits ) do {
  22. Replies
    30
    Views
    3,550

    i thought my was good good.. but i think i...

    i thought my was good good.. but i think i misunderstood on how to do this. I thought that this line would keep getting 1000 digits at a time from the input. Am i wrong?


    if (fgets(myArray,...
  23. Replies
    30
    Views
    3,550

    so if the number entered was 1000000.. etc there...

    so if the number entered was 1000000.. etc there is no way to just get 1000 or even 500 digits at a time into a buffer until ive looped through them all? apart from your file way.
  24. Replies
    30
    Views
    3,550

    ok.. im assured that the input will always be...

    ok.. im assured that the input will always be digits, and im not sure how to break out of both loops from the inner one. But my main problem is still there, when i enter a large number, the final...
  25. Replies
    30
    Views
    3,550

    Hi, I had a go at what you guys said but im...

    Hi,

    I had a go at what you guys said but im having a problem when i enter a really big number in. The final digit in the large number is not printed... any ideas?



    #include <stdio.h>
    ...
Results 1 to 25 of 69
Page 1 of 3 1 2 3