gpt4 book ai didi

c - 我不断收到有关传递参数使指针从整数而不进行强制转换的警告

转载 作者:行者123 更新时间:2023-11-30 14:46:32 25 4
gpt4 key购买 nike

C:\Users\OWNER\Downloads\program1.c|61|警告:传递“get_range”的参数 1 使指针来自整数而不进行强制转换|

巨大的问题非常感谢教授拒绝提供帮助。吃完晚饭休息一下,我就盯着这个问题看了大约3个小时。我还是想不通。如果您能帮助向我解释这一点,以便我了解我做错了什么,我将不胜感激。

/**********************************************************************/
/* */
/* Program Name: program1 */
/* Author: Tommy Lokey */
/* Course: CS 227, Data Structures and Algorithms */
/* Date Written: September 2, 2018 */
/* */
/**********************************************************************/

/**********************************************************************/
/* */
/* I pledge all of the lines in this C program are my own original */
/* work and that none of the lines in this C program have been copied */
/* from anyone else, unless I was specifically authorized to do so by */
/* my CS227 instructor. */
/* */
/* */
/* Signed: _____________________________________ */
/* (signature) */
/* */
/* */
/**********************************************************************/

/**********************************************************************/
/* */
/* This program asks the user for two wholes numbers, it then sums */
/* the range of the two whole numbers. It then displays the sum. */
/* */
/**********************************************************************/

#include <stdio.h> /* printf, scanf */

/**********************************************************************/
/* Symbolic Constants */
/**********************************************************************/
#define COURSE_NUMBER "CS227" /* PCC assigned course number */
#define PROGRAM_NUMBER 1 /* Teacher assigned program number */
#define USER_NAME "Lokey" /* The Programmer's username */

/**********************************************************************/
/* Function Prototypes */
/**********************************************************************/

void print_heading();
/* Print the program heading*/
void get_range(int *p_low_number, int *p_high_number);
int sum_range(int low_number, int high_number);

/**********************************************************************/
/* Main Function */
/**********************************************************************/
int main()
{
int low_number, /* Minimum number entered by user */
high_number; /* Maximum number entered by user */

/* Print the program heading */
printf("\n\n\n\n\n\n");
print_heading();
get_range(low_number, high_number);
printf("\nThe sum of all you numbers between %d and", low_number);
printf("%d (inclusively) is %d", high_number,
sum_range(low_number, high_number));
printf("\nThanks for your range summing. Have a nice day! ;-)");
return 0;
}


/**********************************************************************/
/* Print the program heading */
/**********************************************************************/
void print_heading()
{
printf("\n========================================================");
printf("\n Program Number: %d", PROGRAM_NUMBER);
printf("\n Programmer: %s", USER_NAME);
printf("\n PCC Course Number: %s", COURSE_NUMBER);
printf("\n========================================================");
printf("\nI'll sum whole numbers in a number range (inclusively)");
printf("\n--------------------------------------------------------");
return;
}

/**********************************************************************/
/* Get Range Function */
/**********************************************************************/
void get_range(int *p_low_number, int *p_high_number)
{
printf("\nEnter a range of whole numbers now, lower number first:");
printf("\n What is your small number: ");
scanf(" %d", p_low_number);
printf("\n Give your large number: ");
scanf(" %d", p_high_number);
return;
}

/**********************************************************************/
/* Sum Range Function */
/**********************************************************************/
int sum_range(int low_number, int high_number)
{
int range_counter = 0;

for(low_number; low_number <= high_number; low_number++)
{
range_counter = range_counter + low_number;
}
return range_counter;
}

最佳答案

get_range(low_number, high_number); => get_range(&low_number, &high_number);

关于c - 我不断收到有关传递参数使指针从整数而不进行强制转换的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52213798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com