How can i declare a file name in c language? -


i have c module:

#include "stdafx.h" #include "targetver.h"  #include "libavutil\mathematics.h" #include "libavcodec\avcodec.h"  file filename; 

i did file filename;

this have init function:

void init(const char *filename) {     filename = filename;     avcodec_register_all();     printf("encode video file %s\n", filename); 

so did filename = filename; reason did have function did called start():

void start() {     /* open */     if (avcodec_open2(c, codec, null) < 0) {         fprintf(stderr, "could not open codec\n");         exit(1);     } //    f = fopen(filename, "wb");     errn = fopen_s(&f,filename, "wb");      if (!f) {         fprintf(stderr, "could not open %s\n", filename);         exit(1);     } } 

and in start had filename didn't find wanted use filename instead. i'm getting few errors:

on line: filename = filename; on = symbol i'm getting red line error:

error 1 error c2440: '=' : cannot convert 'const char *' 'file'

then on line: errn = fopen_s(&f,filename, "wb") on filename i'm getting:

error 2 error c2065: 'filename' : undeclared identifier

same error number 2 on line on filename: fprintf(stderr, "could not open %s\n", filename);

then error on filename = filename:

6   intellisense: no operator "=" matches these operands         operand types are: file = const char * 

last error: 7 intellisense: no suitable conversion function "file" "const char *" exists

all wanted declare global filename variable use in places.

file type, used representing open file (it contains file handle, position in file etc). can't store char * in variable of type file, because different types. read file type here.

what want store file name. file name string. use const char * instead. error message tells exactly: "can't convert string file".

error 1 error c2440: '=' : cannot convert 'const char *' 'file' 

reading these errors , trying understand mean can solve problems this. if compiler complains converting 1 type another, it's clear sign you've got confused type of value or variable you're trying assign to.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -