Question

I am getting a bunch of errors. Really need help for C Programming using Microsoft Visual....

I am getting a bunch of errors. Really need help for C Programming using Microsoft Visual. Error Codes listed below code. Thank you.

#define _CRT_SECURE_NO_WARNINGS

#include

#include

#include

typedef struct

{

int *array;

int effectiveSize;

int maximumSize;

} DynamicArray;

void CreateArray(DynamicArray *pDynamicStruct, int initialSize)

{

pDynamicStruct->array = (int *)malloc(sizeof(int) * initialSize);

void ExpandArray(DynamicArray *pDynamicStruct);

{

DynamicArray pDynamicStructNew = (int *)malloc(sizeof(int) * pDynamicStruct->maximumSize * 2);

for (int i = 0l i < effectiveSize; i++);

pDynamicStructNew->array[i] = pDynamicStruct->array[i];

}

//3) Free the old pointer that is stored in the pDynamicSt

free(pDynamicStruct->array);

pDynamicStruct->array = pDynamicStructNew->array;

pDynamicStruct->maximumSize = pDynamicStruct->maximumSize * 2;

}

void PlaceValue(DynamicArray *pDynamicStruct, int value)

{

pDynamicStruct->array[effectiveSize] = value;

effective++;

if (effectiveSize == maximumSize)

ExpandArray(&pDynamicStruct);

}

int main(void)

{

int i;

DynamicArray dynamicArray;

CreateArray(&dynamicArray, 5);

PlaceValue(&dynamicArray, 5);

PlaceValue(&dynamicArray, 10);

PlaceValue(&dynamicArray, 15);

PlaceValue(&dynamicArray, 20);

PrintArray(&dynamicArray);

system("pause");

}

Warning               C4013    'PrintArray' undefined; assuming extern returning int      L 99       

Error (active)      E0144    a value of type "int *" cannot be used to initialize an entity of type "DynamicArray"               35          

Error (active)      E0065    expected a ';'                    41          

Error (active)      E0065    expected a ';'                    41          

Error (active)      E0044    expression must have pointer type                          43          

Error (active)      E0020    identifier "i" is undefined                             43          

Error (active)      E0020    identifier "pDynamicStructNew" is undefined                      53          

Error (active)      E0020    identifier "effectiveSize" is undefined                      65          

Error (active)      E0020    identifier "effective" is undefined                             69          

Error (active)      E0020    identifier "maximumSize" is undefined                   73          

Error      C2146    syntax error: missing ';' before identifier 'i'                          41          

Error      C2065    'effectiveSize': undeclared identifier                        41          

Error      C2059    syntax error: ')'                41          

Error      C2143    syntax error: missing ')' before ';'                             41          

Error      C2232    '->array': left operand has 'struct' type, use '.'                     43          

Error      C2065    'i': undeclared identifier                43          

Error      C2065    'pDynamicStructNew': undeclared identifier                        53          

Error      C2223    left of '->array' must point to struct/union                            53          

Error      C2440    'initializing': cannot convert from 'int *' to 'DynamicArray'                             35              

Error      C2065    'effectiveSize': undeclared identifier                        65          

Error      C2065    'effective': undeclared identifier                69          

Error      C2065    'effectiveSize': undeclared identifier                        73          

Error      C2065    'maximumSize': undeclared identifier                     73          

Warning               C4047    'function': 'DynamicArray *' differs in levels of indirection from 'DynamicArray **'                          75          

Warning               C4024    'ExpandArray': different types for formal and actual parameter 1                              75          

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    int *array;
    int effectiveSize;
    int maximumSize;
} DynamicArray;

void CreateArray(DynamicArray *pDynamicStruct, int initialSize) {
    pDynamicStruct->array = (int *) malloc(sizeof(int) * initialSize);
    pDynamicStruct->effectiveSize = 0;
    pDynamicStruct->maximumSize = initialSize;
}

void ExpandArray(DynamicArray *pDynamicStruct) {
    int *arr = (int *) malloc(sizeof(int) * pDynamicStruct->maximumSize * 2);
    for (int i = 0; i < pDynamicStruct->effectiveSize; i++)
        arr[i] = pDynamicStruct->array[i];
//3) Free the old pointer that is stored in the pDynamicSt
    free(pDynamicStruct->array);
    pDynamicStruct->array = arr;
    pDynamicStruct->maximumSize *= 2;
}

void PlaceValue(DynamicArray *pDynamicStruct, int value) {
    pDynamicStruct->array[pDynamicStruct->effectiveSize] = value;
    pDynamicStruct->effectiveSize++;
    if (pDynamicStruct->effectiveSize == pDynamicStruct->maximumSize)
        ExpandArray(pDynamicStruct);
}

void PrintArray(DynamicArray *pDynamicStruct) {
    int i;
    for(i = 0; i < pDynamicStruct->effectiveSize; ++i) {
        printf("%d ", pDynamicStruct->array[i]);
    }
    printf("\n");
}

int main(void) {
    int i;
    DynamicArray dynamicArray;
    CreateArray(&dynamicArray, 5);
    PlaceValue(&dynamicArray, 5);
    PlaceValue(&dynamicArray, 10);
    PlaceValue(&dynamicArray, 15);
    PlaceValue(&dynamicArray, 20);
    PrintArray(&dynamicArray);
    system("pause");
}
Add a comment
Know the answer?
Add Answer to:
I am getting a bunch of errors. Really need help for C Programming using Microsoft Visual....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The code will not run and I get the following errors in Visual Studio. Please fix the errors. err...

    The code will not run and I get the following errors in Visual Studio. Please fix the errors. error C2079: 'inputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' cpp(32): error C2228: left of '.open' must have class/struct/union (32): note: type is 'int' ): error C2065: 'cout': undeclared identifier error C2065: 'cout': undeclared identifier error C2079: 'girlInputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' error C2440: 'initializing': cannot convert from 'const char [68]' to 'int' note: There is no context in which this conversion is possible error...

  • I'm getting errors that i can't figure out. I need help fixing them. particularly focus on...

    I'm getting errors that i can't figure out. I need help fixing them. particularly focus on the errors they are highlighted in bold on the list code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <ctype.h> #include "stack.h" #include "booleanEvaluation.h" #include "booleanWithError.h" /* evaluatePostfix * input: a postfix expression * output: T, F, or E * * Uses a stack to evaluates the postfix expression and returns the result as a string where "T" denotes true and "F" denotes...

  • Using C, I need help debugging this program. I have a few error messages that I'm...

    Using C, I need help debugging this program. I have a few error messages that I'm not sure how to fix. Here is the code I have: /* * C Program to Print a Linked List in Reverse Order */ #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *next; }; int main() { struct node *p = NULL; struct node_occur *head = NULL; int n; printf("Enter data into the list\n"); create(&p); printf("Displaying the nodes in the list:\n");...

  • I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves...

    I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves the array of structures to file. It is already implemented for you. // You should understand how this code works so that you know how to use it for future assignments. void save(char* fileName) { FILE* file; int i; file = fopen(fileName, "wb"); fwrite(&count, sizeof(count), 1, file); for (i = 0; i < count; i++) { fwrite(list[i].name, sizeof(list[i].name), 1, file); fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...

  • C++ getline errors I am getting getline is undefined error messages. I would like the variables...

    C++ getline errors I am getting getline is undefined error messages. I would like the variables to remain as strings. Below is my code. #include <iostream> #include<string.h> using namespace std; int index = 0; // variable to hold how many customers are entered struct Address //Structure for the address. { int street; int city; int state; int zipcode; }; // Customer structure struct Customer { string firstNm, lastNm; Address busAddr, homeAddr; }; // Functions int displayMenu(); Customer getCustomer(); void showCustomer(Customer);...

  • I need help on this Systems review please! it's due by midnight monday. Question 1 Not...

    I need help on this Systems review please! it's due by midnight monday. Question 1 Not yet answered Points out of 1.00 Flag question Question text Using these declarations: int * numberPointers[3]; int * pointer; int number; Which of the following statements would generate a warning or error? Select one: a. number = pointer; b. *pointer = number; c. pointer = numberPointers; d. numberPointers[2] = &number; e. a., b., and d. f. a. and c. Question 2 Not yet answered...

  • Can you help with this C programming question. I have provided the skeleton code below along...

    Can you help with this C programming question. I have provided the skeleton code below along with the Stack/Data/Process Class for you to see/reference. Along with the Stack/Data type definition.   **SKELTON CODE** #include #include #include Stack* concat_stack(Stack *s1, Stack *s2) { //your code here return NULL; } **STACK CLASS FOR YOU TO REFERENCE** #include #include #include #include Stack* create_stack(int stack_capacity) { Stack *s = (Stack*) malloc(sizeof(Stack)); if (stack_capacity < 1) { fprintf(stderr, "Error(create_stack): invalid capacity, set to 10\n"); s->capacity =...

  • I am getting the Segmentation fault error on the Ubuntu machine but not on macOS. Any...

    I am getting the Segmentation fault error on the Ubuntu machine but not on macOS. Any help would be appreciated. /**** main.c ****/ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <pthread.h> #include <string.h> #define WORD_LEN 6 #define TOP 10 char * delim = "\"\'.“”‘’?:;-,—*($%)! \t\n\x0A\r"; struct Word { char word[30]; int freq; }; int threadCount; int fileDescriptor; int fileSize; off_t chunk; struct Word* wordArray; int arrIndex = 0; pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;...

  • Need C programming help. I've started to work on the program, however I struggle when using...

    Need C programming help. I've started to work on the program, however I struggle when using files and pointers. Any help is appreciated as I am having a hard time comleting this code. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE 100 #define MAX_NAME 30 int countLinesInFile(FILE* fPtr); int findPlayerByName(char** names, char* target, int size); int findMVP(int* goals, int* assists, int size); void printPlayers(int* goals, int* assists, char** names, int size); void allocateMemory(int** goals, int** assists, char*** names, int size);...

  • I NEED HELP WITH C PROGRAMMING. Answer each of the following. Assume that unsigned integers are...

    I NEED HELP WITH C PROGRAMMING. Answer each of the following. Assume that unsigned integers are stored in 4 bytes and that the starting address of the array is at location 200 600 in memory. i)What address is referenced by vPtr + 5? What value is stored at that location? j) Assuming vPtr points to values[6] , what address is referenced by vPtr -= 4? What value is stored at that location? Also ..... For each of the following, write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT