Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
Unknown Quality Score

No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.

0 Endorsements
~4K People Reached
Favorite Forums
Favorite Tags
c x 35
Member Avatar for RexxX

I've learned to write bytes from a file by reading the entire file into a character array and then writing them out to another file using fwrite. Of course, my teacher told me this is both wasteful and a file might not fit into memory, so I should use another …

Member Avatar for WaltP
0
173
Member Avatar for RexxX

I've never written byte variables on my unix shell before, so I don't know if it works or not. I'd been using unsigned ints to get hex numbers as input but I was having trouble with what my input actually was. My friend told me to use byte variables instead …

Member Avatar for Narue
0
135
Member Avatar for RexxX

What way(s) can I reread the same file in C? I've only been able to find C++ tutorials. I tried: [code] fclose(infile); infile = fopen(argv[1], "r"); //error checking [/code] but this code didn't go to the beginning of the file.

Member Avatar for kenji
0
88
Member Avatar for RexxX

I have an assignment I'm working on in C but I didn't want to ask for any code specifically. I just wanted to ask about the methods to use. The program reads a text file where it tells you the number of values to hash. The hash function is completely …

Member Avatar for Narue
0
148
Member Avatar for RexxX

I was wondering which method I should use to declare a 2D array. First, I was going to declare a 2D array of char arr[15][100]. In each text file, there's a number on the first line, and that displays how many columns are in the text file, so I would …

Member Avatar for Ancient Dragon
0
106
Member Avatar for RexxX

If I know the sizes I'm using, I can declare the array as: [code]char arr[20][20];[/code] Is this correct? Well, I want to know how to insert a full string into the array of strings. I thought it might be: [code]fscanf(infile, "%s", *arr[i]);[/code] but this line gave me the error "warning: …

Member Avatar for RexxX
0
152
Member Avatar for RexxX

This is a little program I'm writing to refresh my knowledge of C and I know it's wrong, but everything I've tried in order to fix it isn't working. [code] #include <stdio.h> #include <string.h> int main() { int const STR_LENGTH = 255; char str[STR_LENGTH]; int n=0,i=0; printf("Please enter a word: …

Member Avatar for death_oclock
0
110
Member Avatar for RexxX

If I have a struct defined as [code] struct node { char *data; struct node *next; }; typedef struct node* nodePtr; nodePtr newNode; ... int main(void) { newNode = (nodePtr *) malloc(sizeof (nodePtr)); //dynamically allocate memory if(newNode == NULL) { printf("Error: could not allocate a new node\n"); exit (1); } …

Member Avatar for sukhmal.sena
0
94
Member Avatar for RexxX

Say I have [code] #include<iostream.h> int tempNum; struct node { int data; struct node *next; }; struct node *newNode = NULL; int main(void) { tempNum = 5; newNode->data = tempNum; //gives seg fault } [/code] *edit - I'm trying to add tempNum to the very first node. I haven't worked …

Member Avatar for Aia
0
100
Member Avatar for RexxX

Back to where I was, now I'm learning how to use fgetc properly. Does fgetc read in a character? If so I can't find my error in my code and I'm getting a a segfault. Can you help fix it and explain why it doesn't work? Thanks [code]#include<stdio.h> //declare variables …

Member Avatar for Aia
0
216
Member Avatar for RexxX

I'm getting a segmentation fault when I try to run my program. It's probably because I'm not referencing my pointer to a string right, or dereferencing whatever it's called. This is basically what my code looks like. [code] #include <stdio.h> FILE *myFP; char filename[20]; char *pstr = finlename; void func(char …

Member Avatar for Aia
0
108
Member Avatar for RexxX

I want to store a byte from fread as type char, and then be able to perform comparison operations on that byte as an int. I have [quote] int num; char buffer; num = fread(buffer, 1, 1, myFP); [/quote] and I'm sure it's not right.

Member Avatar for John A
0
112
Member Avatar for RexxX

I'm better at C++ than C right now and I forgot how to use arrays in functions from main. I want to do something like [quote]void fileReader(infile[] ); [/quote]. Is infile supposed to be a pointer and if so how is it written?

Member Avatar for Aia
0
75
Member Avatar for RexxX

Also argument 2 makes integer from a pointer with a cast. One argument is a struct declared in an included library. It's declared like: [code]struct pixelst *lzwArr; lzwArr = (struct pixelst *) malloc(pixels); // pixels is an int[/code] the second argument is an unsigned int 2D array. It's used in …

Member Avatar for Aia
0
3K