mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
using long long int for pritf compatibility
This commit is contained in:
parent
1d8d07efc9
commit
de027fe4ff
@ -1,13 +1,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int64_t get_product(FILE *fp, long start_pos, int num_digits)
|
long long int get_product(FILE *fp, long start_pos, int num_digits)
|
||||||
{
|
{
|
||||||
char ch = ' '; /* temporary variable to store character read from file */
|
char ch = ' '; /* temporary variable to store character read from file */
|
||||||
uint8_t num = 0; /* temporary variable to store digit read */
|
uint8_t num = 0; /* temporary variable to store digit read */
|
||||||
int64_t prod = 1; /* product accumulator */
|
long long int prod = 1; /* product accumulator */
|
||||||
int count = 0; /* we use this variable to count number of bytes of file read */
|
int count = 0; /* we use this variable to count number of bytes of file read */
|
||||||
|
|
||||||
/* accumulate product for num_digits */
|
/* accumulate product for num_digits */
|
||||||
for (int i = 0; i < num_digits; i++, count++)
|
for (int i = 0; i < num_digits; i++, count++)
|
||||||
@ -49,7 +48,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int num_digits = 4;
|
int num_digits = 4;
|
||||||
int64_t prod, max_prod = 0;
|
long long int prod, max_prod = 0;
|
||||||
|
|
||||||
/* if second command-line argument is ge=iven,
|
/* if second command-line argument is ge=iven,
|
||||||
* use it as the number of digits to compute
|
* use it as the number of digits to compute
|
||||||
|
Loading…
Reference in New Issue
Block a user