but i did.. ive got the following includes
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Type: Posts; User: waxydock
but i did.. ive got the following includes
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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...
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;
Thanks MacGyver, nvoigt this solution works great!.. thanks
counter = counter + snprintf(myarray+counter,sizeof(char)*1000,"%d",run);
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.
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:
...
ok..
after this
char szBuffer[BUFSIZ];
int num = 100;
snprintf(szBuffer,sizeof(szBuffer),"%d",num);
""Take 5 and put '5' inside for example?""
exactly
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;
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 */
...
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 =...
cheers, ill give it ago
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...
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...
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...
Hi everyone,
Is there a way i can make these functions more efficient?
int UlitmateCollapse (int num) {
int ones, sum = 0;
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) {
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
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...
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?
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 {
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,...
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.
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...
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>
...