Here's the line:
aStruct->name = string;
Type: Posts; User: CS_Student8337
Here's the line:
aStruct->name = string;
Were aren't allowed to use buffers in the assignment for some reason
Hmm.. that's how I was trying to do it but I keep getting this error when I try to compile:
error: invalid type argument of ‘->’
Ok. One quick, little question. How do I get one of the pointers in my struct to point to the string??
Cool. Thank you. I'll post again if I run into any problems
Right. I didn't include any code to check if they return NULL. I know I should for my program though. In the code I just posted I used fgetc(). Would it be possible to substitute fgets() instead?
I thought that's what it was but I wasn't sure because the instructions say that the strings shouldn't have any wasted space.. So, is it ok to do something like this?
int capacity = 1;
int...
Ok, part of my assignment for school is to create a struct with 2 char pointers in it. These pointers are supposed to point to a couple of dynamically allocated strings and I'm supposed to create a...
Thanks to everyone who posted. I think I have it working properly now
No, messing with the sizes of fegts didn't help.
#include <stdio.h>
#include <string.h>
#define MAX 6
int main(void)
{
int c, i, j, k, output;
char arrayA [MAX+1], arrayB[MAX+1];
Thank you for the response Cas. Taking the input into a huge temporary array was originally what I was going to do but it's expressly forbidden in one of the bullets of the assignment. But I have...
Thanks for the help. That was a silly error on my part. I have another question though and since it's somewhat related, I hope it's ok to ask it in this thread instead of creating another one.
...
What's the best way to truncate user input to a certain number of characters ( ie.6 characters)? tried using the following code but it doesn't seem to work properly for certain inputs.
If I input...
Ok. I'm doing a Towers of Hanoi project and it's supposed to be a multi file program. I keep getting this error and I can't figure out why.
hanoi.c:4: error: redefinition of ‘hanoi’
hanoi.h:5:...
Nevermind. Global or static variable, duh
Ok. I've got a pretty decent understanding of recursion itself now and am now working on my Tower program Everything's working well but I'd like to spice up my output a bit. Currently my output looks...
Thanks for that link. I don't have the time to check it out right this second but I'm gonna look over it tonight or tomorrow morning. From the glance I had of it, it looks like exactly what I need,...
Thanks for the quick response. I think that it's making a bit more sense.
So for n=1 the if statement triggers, the function calls itself for 0, the if statement DOESN'T trigger. Then the print...
void dohanoi(int N, int from, int to, int using)
{
if (N > 0)
{
dohanoi(N-1, from, using, to); //1
printf ("move %d --> %d\n",...