No, I wasn't appending to the string twice. Anyway - ended up figuring out that myOutput had too much memory allocated to it - just had to use a reduced size char*.
Sometimes I feel like C is a...
Type: Posts; User: TieFighter
No, I wasn't appending to the string twice. Anyway - ended up figuring out that myOutput had too much memory allocated to it - just had to use a reduced size char*.
Sometimes I feel like C is a...
I do have <string.h> included. I'm really not seeing why there's a segmentation fault when I try to concatenate these two strings together. Any help would be greatly appreciated. In the end this...
well, according to the man entry it should work with
this format
My code works for one of my school projects, but there are still compiler warnings. May someone please help me figure out how to clean these up? The following are the code parts that are giving the...
Okay... you just defined how pass by reference is implemented. If any professor calls that pass by value, then I'd ask for some of my class money back.
No, I definitely meant method. This question isn't necessarily about C.
In C you can pass by reference (int &a) rather than (int a). Even in Java you may pass by reference provided your parameter...
My bad - I meant method instead of array. I also don't think you meant to imply all parameters are passed by value.
pass by reference is when the parameter references the original value passed into the method (by using the memory location's address)
pass by value is when a copy of the value is given to the method...
try putting break; after each case.
strings is changed to string - works perfectly, thank you.
well, yeah it should never be reached, but if it ever is - then you know the name probably wasn't entered.
Well, here's the end result - after making a "removeName" function to compliment the "enterName" one. Can anyone get this to compile on their machine without warnings?
/**********
* Author:...
Yes, and strings.h
Wait, I think I got it now - should have used strlen instead of sizeof to malloc enough memory for the name entered.
arrayOfNames[m] = malloc(strlen(name) + 1);
...
That definitely seemed to work for storing my strings in the array. Thank you. Now... I get an error when trying to free a string that is too large for some reason. I'm not sure if there are any...
okay, so even with the warning about memmove it still compiles, but it's giving me output that's truncated from what string it's supposed to store like the following:
CREATED ARRAY AT MEM...
Yes. I am using Ubuntu. Unfortunately libc6-dev was already installed and it still wasn't displaying manual pages for C functions. I poked around with a search engine quick after you mentioned I...
penguin@penguin-laptop:~$ man malloc
No manual entry for malloc
penguin@penguin-laptop:~$ man memcpy
No manual entry for memcpy
penguin@penguin-laptop:~$ man memmove
No manual entry for memmove...
When I ask some people for help in C code they ask if I've checked the man entry for the function. It seems to be a Unix command line argument - and I've sucessfully been able to pull up entries for...
How would anyone check if the program worked if you can't use IO functions from the standard library or self-written (you wouldn't be able to output to a file or a terminal window, or anything)?
...
Alright, nice - the method compiles with the addition of the <stdbool.h> library. It is still giving me a warning. I'm not sure why the compiler is telling me I'm trying to redefine memmove(). I...
Okay, you need to get rid of the: "void master() {}" in the header file. The function signatures look good. If you define something in either your header or the C file, the you don't need to...
Good point - C was created specifically to design the Unix OS. Why anybody would design anything other than a compiler or OS with it is beyond me.
I'm still struggling with how to implement...
okay, so it doesn't store the integer separate from the string, rather it embeds it, so if I did boundary value analysis on this code it would crash and burn near the upper bounds. Cool.
When...
so, in short, what you're saying is:
1. sizeof(int) doesn't actually give me the size of an integer
2. nobody is updating the C programming language for 64 bit machines so we have to cover that...
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
char ** createArray (int arraysize) {
char **arrToCreate;
arrToCreate = (char**)malloc(arraysize * sizeof(char *));
...