So my assignment is to create a program that calls for a function in main that dynamically allocates an array[3] and then have pointers with multiple levels of indirection and pass them by reference so they are not lost after the function. Here is my code:
Next part is to ask user for two non-negative numbers and then get the length of those numbers and create an array. for the size of each number they input. Then to separate those numbers and add the cross-sums.
How to ADD a call to the FindMostExpensive function AFTER the main display loop, and use the index returned to display the information about the most expensive car?
// Session7.cpp : Defines the entry point for the console application. //using struct // reading from file // using functions
#include "stdafx.h" #include <iostream> #include <iomanip> // only used to tidy up the console output here #include <fstream> // added file handling
I'm writing code to create an array of integer and let user input choice to display, replace, add new element, etc.I created a header file in the header file there's a function:
Code:
int display_one_element(int* array, int num_of_elements, int position) { if(num_of_elements < position || position < 0) { printf("Position out of bound. "); return 1; } return array[position-1]; }
My code seems to work fine but there's an error message right next to my function call: 1.too many arguments provided to function like macro invocation 2.Expression result unused
I tried to move the function from header file to c source file. but other functions in the header file works fine and this doesn't work with the error message.
Get user input should be done in a function. The function should read the product number, price per unit, and quantity sold and return them to the main().
Display the value of product number, price per unit and quantyty sold in main().
The function is supposed to return value from the file in my main, but I am getting empty value. I am trying to get better with pointer. Right now just teaching myself.
right now the only way for this code to show value is when in put the putchar(*ps) inside my readfile function. I would like to readfile to return value and print in the main function.
I try to use passing function as argument but I'm stuck. I have two questions: First, I try to call uppercase and open .txt in tfm Second, How can I read characters from in.txt as string and assign to char content[] ?
#include <stdio.h> void tfm( char str_filename[], void(*pf_convertion)( char content[])); void uppercase(char content[]); //converts all letters to uppercase int main(){ puts("-------------------------------"); printf("tfm: "); tfm("in.txt", uppercase);