fopen

warning: fopen() call [duplicate]

▼魔方 西西 提交于 2020-01-06 23:18:48
问题 This question already has answers here : Why am i getting this warning in “if (fd=fopen(fileName,”r“) == NULL)”? (6 answers) Closed last year . hi I'm programming with stdlib under linux. The gcc emits the following warning for the following line of code, any idea why is that? FILE *fd; if ( fd = fopen( filename, "rw" )== NULL ) { and the warning is: warning: assignment makes pointer from integer without a cast. How this can be happen , according to the stdlib documentation the return type of

多媒体文件格式(五):PCM / WAV 格式

こ雲淡風輕ζ 提交于 2020-01-06 21:30:00
一、名词解析 PCM(Pulse Code Modulation)也被称为脉码编码调制,PCM中的声音数据没有被压缩,它是由模拟信号经过采样、量化、编码转换成的标准的数字音频数据。采样转换方式参考下图进行了解: 音频采样包含以下几大要素: 1. 采样率 采样率表示音频信号每秒的数字快照数。该速率决定了音频文件的频率范围。采样率越高,数字波形的形状越接近原始模拟波形。低采样率会限制可录制的频率范围,这可导致录音表现原始声音的效果不佳。根据奈奎斯特采样定理,为了重现给定频率,采样率必须至少是该频率的两倍。例如,一般CD唱片的采样率为每秒 44,100 个采样,因此可重现最高为 22,050 Hz 的频率,此频率刚好超过人类的听力极限 20,000 Hz。 图中A是低采样率的音频信号,其效果已经将原始声波进行了扭曲,B则是完全重现原始声波的高采样率的音频信号。 数字音频常用的采样率如下: 2. 位深度 位深度决定动态范围。采样声波时,为每个采样指定最接近原始声波振幅的振幅值。较高的位深度可提供更多可能的振幅值,产生更大的动态范围、更低的噪声基准和更高的保真度。 位深度越高,提供的动态范围越大。 二、PCM 在上面的名词解析中我们应该对PCM有了一定的理解和认识,下面我们将对PCM做更多的讲解。 1. PCM音频数据存储方式 如果是单声道的文件,采样数据按时间的先后顺序依次存入

MATLAB newbie: problem reading in file when the file name is stored in a string

a 夏天 提交于 2020-01-06 05:10:13
问题 I am using Matlab to read in and process calculation results. I use fopen. My problem is that I currently have to specify a path to each file each time I need to use it in my processing code. For example, this works: fid = fopen('/Users/me/Desktop/Result1/velocity.tbl', 'r+'); liqmass = textscan(fid, '%f %*f %*f %*n %f %*n %*n %*n %*n %*n %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f %*f

Is it possible to prevent adding BOM to output UTF-8 file? (Visual Studio 2005)

半城伤御伤魂 提交于 2020-01-06 03:16:06
问题 I need some help. I'm writing a program that opens 2 source files in UTF-8 encoding without BOM. The first contains English text and some other information, including ID. The second contains only string ID and translation. The program changes every string from the first file by replacing English chars to Russian translation from the second one and writes these strings to output file. Everything seems to be ok, but there is BOM appears in destination file. And i want to create file without BOM

Program cannot open file, but the file is already there

ぃ、小莉子 提交于 2020-01-06 02:59:06
问题 I am writing a program that will open an image file, but strange thing happened. This is the output from cmd: C:\Users\Karl\Pictures>testcvconsole mypic.jpg argv[0]==testcvconsole argv[1]==mypic.jpg fopen is null strerror(errno)==No such file or directory Are there something I should consider when fopen simply failed to open my file when the file is right there along side with the executable file in the same directory? This is on Windows 7, Visual Studios Express 2010. C++. EDIT : code below

《PHP和MySQL Web开发》学习之二--数据的存储与检索

本小妞迷上赌 提交于 2020-01-05 23:53:14
最近这段时间主要将时间和精力花在看《代码大全》和《Clean Code》上了,今晚操作了一下久违的PHP,现将第二章的主要内容摘要如下。书很久之前就看了,一直没有写笔记,突然发现很多语法已经有些生疏,看来学习一门新的语言还是要通过练习,练习再练习。当然,写笔记的过程也是一个记忆的过程,俗话说:好记心当不得烂笔头是也。 存储数据有两种基本方法:保存到普通文件,或者保存到数据库中。 1.文件处理 将数据写入文件的三个步骤:(1)打开这个文件,如果不存在则创建;(2)将数据写入文件;(3)关闭文件 从文件中读取数据的三个步骤:(1)打开这个文件,如果文件不存在则正确的退出;(2)从文件中读取数据;(3)关闭文件。 2.打开文件 (1)使用fopen()来打开文件 如要将一个顾客订单写入Bob订单文件,可以使用如下语句打开该文件: $fp = fopen("%DOCUMENT_ROOT/../orders/orders.txt", 'w'); 上面代码中,使用了内置变量$_SERVER['DOCUMENT_ROOT'],指向web服务器文档树的根。用".."表示文档根目录的父目录。 在Unix系统中,根目录是/,在windows系统中,根目录是C:\。 在Unix环境下,目录中的间隔符是正斜线(/)。windows平台下可以使用正斜线或者反斜线,如果使用反斜线,则需要使用转义字符

【PHP】文件写入和读取详解

自闭症网瘾萝莉.ら 提交于 2020-01-05 23:52:53
文章提纲: 一.实现文件读取和写入的基本思路 二.使用fopen方法打开文件 三.文件读取和文件写入操作 四.使用fclose方法关闭文件 五.文件指针的移动 六.Windows和UNIX下的回车和换行 一.实现文件读取和写入的基本思路: 1.通过fopen方法打开文件:$fp =fopen(/*参数,参数*/),fp为Resource类型 2.进行文件读取或者文件写入操作(这里使用的函数以1中返回的$fp作为参数) 3. 调用fclose($fp)关闭关闭文件 二:使用fopen方法打开文件 fopen(文件路径[string],打开模式[string]) <1>fopen的第一个参数为文件路径 写文件路径的方式:1绝对路径,2相对路径 1绝对路径: 在windows下工作的小伙伴们应该很熟悉,windows下的路径分隔符是“\”而不是“/”,但我们在写入路径时不能以钦定的“\”为分隔符 那如果我们以“\”分隔符写入路径会怎样呢? <?php $fp = fopen("C:\wamp64\www\text.txt",'w'); ?> 运行后报错,提示路径参数无效 所以我们要把分隔符“\”换成“/”: <?php $fp = fopen("C:/wamp64/www/text.txt",'w'); ?> 运行时无报错,说明参数是有效的。 【注意】fopen函数不能理解“\”分隔符

PHP:读写文件一些说明

 ̄綄美尐妖づ 提交于 2020-01-05 23:52:31
一,PHP如何读取文件 PHP读取文件可以读取当前服务器或远程服务器中的文件。其步骤是:打开文件、读文件和关闭文件。 1,PHP如何打开文件 使用PHP 函数fopen() 打开一个文件,fopen()一般使用2个参数表示打开文件的路径和文件模式。比如: $fp=fopen("../cnbruce.txt",'w'); 其中 "../cnbruce.txt" 就表示打开的cnbruce.txt文件的路径(相对当前执行程序文件的路径),'w'表示以只写的方式打开该文本文件。 附录:fopen()函数的文件模式总结 r 只读——读模式,打开文件,从文件头开始读 r+ 可读可写方式打开文件,从文件头开始读写 w 只写——写方式打开文件,同时把该文件内容清空,把文件指针指向文件开始处。如果该文件已经存在,将删除文件已有内容;如果该文件不存在,则建立该文件 w+ 可读可写方式打开文件,同时把该文件内容清空,把文件指针指向文件开始处。如果该文件不存在,则建立该文件 a 追加 以只写方式打开文件,把文件指针指向文件末尾处。如果该文件不存在,则建立该文件 a+ 追加 以可读可写方式打开文件,把文件指针指向文件末尾处。如果该文件不存在,则建立该文件 b 二进制 用于于其他模式进行连接。建议使用该选项,以获得更大程度的可移植性 注意,如果fopen()函数调用失败,函数将返回false

“failed to open stream: FTP server reports 550” when accessing file on Microsoft FTP Service using wrapper

余生颓废 提交于 2020-01-05 09:05:39
问题 In PHP, you have wrappers for ftp and ftps to allow you access files on an FTP using fopen. I want to use the wrapper to download a file as a stream. My simplified code: // eg. $url = "ftp://username:password@server.com/directory-with-dash/file.mp3"; $url = 'ftp://' . urlencode($username) . ':' . urlencode($password) . '@' . $server . $path . '/' . $filename; $ctx = stream_context_create(array('ftp' => array('resume_pos' => 0))); $fin = fopen($url, 'r', false, $ctx); Error: Warning: fopen(ftp

Simple fopen and fprintf not working

人走茶凉 提交于 2020-01-04 23:05:51
问题 I have a simple program which opens a file and write a text into the file. However, the fopen is always returning BadPtr as seen in debug mode in Microsoft Visual c++, 2010 . Below is the warning that is displayed in VS C++, 2010 : mysample\mysample\main.c(6): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc