d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Halp Me
Add Reply New Topic New Poll
Member
Posts: 43,014
Joined: Apr 5 2008
Gold: Locked
Trader: Scammer
Sep 3 2017 05:24pm
Trying to capture output, yes I am new to coding and this is part of an intro course.

#include <stdio.h>

#define MIN 1
#define MAX 30

FILE *fp;

int main(void) {
int i;

fp = fopen_s("csis.txt");

printf("%10s %10s %10s %10s %10s\n", "Value", "Square", "Cube", "4th", "5th");
fprintf(fp, "%10s %10s %10s %10s %10s\n", "Value", "Square", "Cube", "4th", "5th");

printf("%10s %10s %10s %10s %10s\n", "-----", "------", "----", "---", "---");
fprintf(fp, "%10s %10s %10s %10s %10s\n", "-----", "------", "----", "---", "---");

for (i = MIN; i <= MAX; ++i) {
printf("%10d %10d %10d %10d %10d\n", i, i * i, i * i * i, i * i * i * i, i * i * i * i * i);
fprintf(fp,"%10d %10d %10d %10d %10d\n", i, i * i, i * i * i, i * i * i * i, i * i * i * i * i);


}

fclose(fp);
return 0;
}


(24): warning C4047: 'function': 'FILE **' differs in levels of indirection from 'char [9]'
: warning C4024: 'fopen_s': different types for formal and actual parameter 1
error C2198: 'fopen_s': too few arguments for call
: warning C4047: '=': 'FILE *' differs in levels of indirection from 'errno_t'


This post was edited by Fizzical on Sep 3 2017 05:25pm
Member
Posts: 1,039
Joined: Jul 8 2008
Gold: 1,939.50
Sep 4 2017 01:15pm
fopen_s requires more paramaters. You're passing in one param ("csis.txt") and you should be passing 3. See https://msdn.microsoft.com/en-us/library/z5hh6ee9.aspx
Member
Posts: 12,703
Joined: May 17 2013
Gold: 12,935.00
Sep 4 2017 03:59pm
Quote (waraholic @ 4 Sep 2017 21:15)
fopen_s requires more paramaters. You're passing in one param ("csis.txt") and you should be passing 3. See https://msdn.microsoft.com/en-us/library/z5hh6ee9.aspx


fopen_s(&fp, "csis.txt", "rw");
Member
Posts: 43,014
Joined: Apr 5 2008
Gold: Locked
Trader: Scammer
Sep 4 2017 04:03pm
I figured it out.

Just turned off the properties that gave warning to open f_open in safe
Member
Posts: 11,271
Joined: Apr 29 2016
Gold: 6,183.00
Oct 14 2017 02:07pm
nvm

This post was edited by Banny_Bum on Oct 14 2017 02:09pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll