/*
* word_cnt.c
* This program reads a file and counts the words in it.
*/
"/* * word_cnt.c * This program reads a file and counts the words in it. */"
- Ron Wein's C Examples: word_cnt.c (在「Google 網頁註解」中檢視)
/*
* word_cnt.c
* This program reads a file and counts the words in it.
*/
"/* * word_cnt.c * This program reads a file and counts the words in it. */"
- Ron Wein's C Examples: word_cnt.c (在「Google 網頁註解」中檢視)
A TUTORIAL ON POINTERS AND ARRAYS IN C
by Ted Jensen
Version 1.2 (HTML version)
Feb. 2000
This material is hereby placed in the public domain
Available in various formats via
http://pweb.netcom.com/~
"A TUTORIAL ON POINTERS AND ARRAYS IN C by Ted Jensen Version 1.2 (HTML version) Feb. 2000 This material is hereby placed in the public domain Available in various formats via http://pweb.netcom.com/~tjensen/ptr/cpoint.htm"
- A Tutorial on Pointers and Arrays in C (在「Google 網頁註解」中檢視)
The C Programming Language
References
* The C Programming Language (second edition - ANSI C),
Brian W. Kernighan and Dennis M. Ritchie,
Prentice Hall, Inc., 1988.
* A Book on C (fourth edition),
Al Kelley and Ira Pohl,
Addison-Wesley, 1997.
Examples
Examples marked by the (advanced) symbol contain slightly more advanced material and will not be shown in class.
"Examples Examples marked by the symbol contain slightly more advanced material and will not be shown in class."
- The C Programming Language (在「Google 網頁註解」中檢視)
利用strstr和sscanf解析GPS信息
作者:杨硕,华清远见嵌入式学院讲师。
考察C程序员是否合格的一个重要标准就是看他操作字符串的能力,
比如说我们要做一个GPS导航的项目,
GPS输出的数据格式如下:
$GPGGA,121252.000,3937.3032,N,
$GPRMC,121252.000,A,3958.3032,
$GPVTG,359.95,T,,M,15.15,N,28.
$GPGGA,121253.000,3937.3090,N,
$GPGSA,A,3,14,15,05,22,18,26,,
$GPGSV,3,1,10,18,84,067,23,09,
$GPGSV,3,2,10,21,32,199,23,14,
$GPGSV,3,3,10,29,07,074,,30,
可以看到,GPS模块发送过来的原始数据有很多,
$GPRMC,121252.000,A,3958.3032,
因此我们需要做的就是从读取的数据中截取以$
假设从串口读取的数据存放在一个字符串指针char *raw_buf指向的内存单元里,首先我们通过ANSI C提供的strstr()函数找到以$GPRMC开头以换行符’
/* find "$GPRMC" from raw_buf */
if ((wellhandled_string = strstr(raw_buf, “$GPRMC”)) != NULL)
{
for (i=0; i
"利用strstr和sscanf解析GPS信息 作者:杨硕,华清远见嵌入式学院讲师。 考察C程序员是否合格的一个重要标准就是看他操作字符串的能力,一个合格的C程序员应该可以熟练的对字符串进行拆分、组合、格式转换以及搜索定位,从一堆数据中提取出有效信息。 比如说我们要做一个GPS导航的项目,需要读取GPS模块以ASCII码的形式发送过来的数据,然后对这些数据进行处理,提取我们需要的信息。这就涉及到很多操作字符串的问题。下面就以此为例,利用strstr函数和sscanf函数解析GPS数据。"
- 利用strstr和sscanf解析GPS信息-- 嵌入式学院(华清远见旗下品牌) (在「Google 網頁註解」中檢視)
第一:举例说,你有个一依赖A用到了spring-2.0.5;
第二:从eclipse的maven插件来说,add dependency的时候,一旦仓库更新了,
第三:开发者们同步仍然有困难。
maven的支持者们,我们是活在现实世界中的生命,
我仍然是maven的用户,但是我在瞪着眼睛等待一个新的工具,
"第一:举例说,你有个一依赖A用到了spring-2.0.5;后来spring在仓库换地方了(这种事情太多了,看看maven混乱的仓库吧),而你需要的是最新的spring2.5.1,那么你编译的时候就会同时有一堆spring2.0.5的文件和spring2.5的文件;那么你需要手动的排除2.0.5的相关资源。问题是在maven体系里面,这种情况非常常见,大量的依赖混在一起的时候,你看着mvn install之后lib文件夹下乱七八糟的jar真是欲哭无泪啊,很多jar是同一个库的不同的版本,这些版本的依赖可能还不同,导致问题进一步的恶化。"
- 关于Maven,不吐不快。 - develop - JavaEye论坛 (在「Google 網頁註解」中檢視)
qsort: sorting array of strings, integers and structs
abstract
qsort() is standard C function for sorting arrays. It is defined by ISO C standard, and implemented in most C/C++ standard libraries(stdlib.h). This article contains an example of using qsort() for sorting integers, strings and structs.
compatible
# Any ANSI C compiler
# Should work with most C++ compilers
qsort() takes four arguments:
void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *));
* base — is a pointer to the beginning of data array
* nel — is a number of elements
* width — is a size of each element (in bytes)
* compar — is a callback function (pointer to function), which does comparison and returns positive or negative integer depending on result.
This example contains three separate functions sort_integers_example(), sort_cstrings_example() and sort_structs_example().
* sort_integers_example() uses int_cmp() as compar callback. Additional function print_int_array is used for printing integer array contents.
* sort_cstrings_example() uses cstring_cmp() as compar callback. Additional function print_cstring_array is used for printing string array contents.
* sort_structs_example() uses struct_cmp_by_price() and struct_cmp_by_product() as compar callbacks. Additional function print_struct_array is used for printing array of struct.
"qsort: sorting array of strings, integers and structs abstract qsort() is standard C function for sorting arrays. It is defined by ISO C standard, and implemented in most C/C++ standard libraries(stdlib.h). This article contains an example of using qsort() for sorting integers, strings and structs."
- qsort: sorting array of strings, integers and structs (在「Google 網頁註解」中檢視)
結構(struct)的大小問題
在記憶體配置的時候,因為效率考量,
並且會以其中最大的元素為單位,配置整數倍的記憶體
例如同樣是char, short, int三個元素
"結構(struct)的大小問題 在記憶體配置的時候,因為效率考量,預設會依照元素大小整數倍的對齊並且會以其中最大的元素為單位,配置整數倍的記憶體例如同樣是char, short, int三個元素"
- Coding James: 結構(struct)的大小問題 (在「Google 網頁註解」中檢視)
Structure
結構化的資料型態一
這一星期的課程,我們將面對C語言中比較深入的話題,
"Structure 結構化的資料型態一 這一星期的課程,我們將面對C語言中比較深入的話題,怎麼表達複雜的資料型態,怎麼做到一言以蔽之,簡潔而有力的C語言寫法。還有,如果你覺得int,char,float...不夠親切,你希望用更好的名稱來表達你的變數,這時候你需要typedef的語法。如果這都還不夠,還不能符合你的要求,還有以bit為單位的處理(bit manupulation),以及列舉(enumeration)的資料型態。"
- Structure I (在「Google 網頁註解」中檢視)
Abstract
本文介紹如何將struct array寫入binary file,並從binary file讀出struct array。
"Abstract 本文介紹如何將struct array寫入binary file,並從binary file讀出struct array。 Introduction C語言 / fwrite_fread_struct_array.c"
- (原創) 如何將struct array寫入文字檔? 如何從文字檔讀出struct array? (C/C++) (C) - 真 OO无双 之 真乱舞书 - 博客园 (在「Google 網頁註解」中檢視)
不錯的一句話
inception 電影評論
事實並不存在,只是我們,陷在其中。
"现实并不存在,只是我们,陷在其中——《Inception》 - [电影] 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://parasite.blogbus.com/logs/69692744.html"
- 现实并不存在,只是我们,陷在其中——《Inception》 - 我和E的宇宙飞船 - 博客大巴 (在「Google 網頁註解」中檢視)
Q: What's the difference between text and binary I/O?
A: In text mode, a file is assumed to consist of lines of printable characters (perhaps including tabs). The routines in the stdio library (getc, putc, and all the rest) translate between the underlying system's end-of-line representation and the single \n used in C programs. C programs which simply read and write text therefore don't have to worry about the underlying system's newline conventions: when a C program writes a '\n', the stdio library writes the appropriate end-of-line indication, and when the stdio library detects an end-of-line while reading, it returns a single '\n' to the calling program. [footnote]
In binary mode, on the other hand, bytes are read and written between the program and the file without any interpretation. (On MS-DOS systems, binary mode also turns off testing for control-Z as an in-band end-of-file character.)
Text mode translations also affect the apparent size of a file as it's read. Because the characters read from and written to a file in text mode do not necessarily match the characters stored in the file exactly, the size of the file on disk may not always match the number of characters which can be read from it. Furthermore, for analogous reasons, the fseek and ftell functions do not necessarily deal in pure byte offsets from the beginning of the file. (Strictly speaking, in text mode, the offset values used by fseek and ftell should not be interpreted at all: a value returned by ftell should only be used as a later argument to fseek, and only values returned by ftell should be used as arguments to fseek.)
In binary mode, fseek and ftell do use pure byte offsets. However, some systems may have to append a number of null bytes at the end of a binary file to pad it out to a full record.
See also questions 12.37 and 19.12.
"Q: What's the difference between text and binary I/O?"
- Question 12.40 (在「Google 網頁註解」中檢視)
CSC 209 course notes
Course notes available so far:
* Software tools
* Shell programming
* The unix filesystem
* The C programming language (intro)
* C data types; pointers and arrays
* C: printf and scanf
* argc and argv in C
* C strings
* C files
* getopt example
* struct, malloc
* what is being covered about unix processes
* Process memory layout and OS considerations
* Socket examples
(It's not being taught this term, but I have some detailed notes which I'm fond of about the AWK programming language, which is often used in shell scripts for various data processing and string munging tasks which are a bit more sophisticated than what cut and join and such can do.)
http://www.dgp.toronto.edu/~
"CSC 209 course notes Course notes available so far:"
- CSC 209 course notes (在「Google 網頁註解」中檢視)
推 phstudy:%s改成%[^,] 07/17 19:16
推 dann1:成功了~ 大大可以解釋一下[^,]這個的意思嗎 07/17 19:35
推 dann1:研究了一下好像是規定字串結尾是逗號 那^的意思是無視嗎 07/17 19:39
推 TsinTa:^是not的意思,[^,]
推 loveme00835:regular expression 07/17 19:48
→ loveme00835:可以搭配fread、fwrite, 把整個結構變數都用二進位方 07/17 20:13
→ loveme00835:式存放在檔案中, 這樣也可以支援隨機存取 07/17 20:14
→ loveme00835:http://ppt.cc/@qjm 07/17 20:15
"#include <stdio.h> #include <stdlib.h> typedef struct { int age; char name[ 10 ]; int weight; }Person; int main() { Person person = { 20, "Jane", 50 }; // 存資料進檔案 FILE *file = fopen( "test.txt", "wb" ); fwrite( &person, sizeof(Person), 1, file ); fclose( file );"
- Paste #281215 | LodgeIt! (在「Google 網頁註解」中檢視)
Q&&A
參考來源:"Hi, I need a program in C that is capable of writing the multiple records into a file.And another function that should read the same data from the from the file and store it in the approptiate data structure."
- Read multiple records from a file and store it in a structure (在「Google 網頁註解」中檢視)
Program for sorting records in a file, Using linked list and insertion sort, records are sorted.
參考來源:"Program for sorting records in a file, Using linked list and insertion sort, records are sorted."
- Program for sorting records in a file, Using linked list and insertion sort, records are sorted. « hackattacking.com (在「Google 網頁註解」中檢視)
www.cs.duke.edu/~des/scripts/
#
# rsort : Sort multi-line text records.
The Scriptorium
Daniel E. Singer
Department of Computer Science
Duke University
"rsort : Sort multi-line text records."
- Dan's Scripts Page (在「Google 網頁註解」中檢視)
Mutiple-Line record in AWK
這是值得參考的名詞叫作多行的輸入。
other site:
http://www.math.utah.edu/docs/
"Multiple-Line Records In some databases, a single line cannot conveniently hold all the information in one entry."
- The GNU Awk User's Guide - Reading Input Files (在「Google 網頁註解」中檢視)
Creating Linked Lists in C++
What is a linked list?
A linked list is a data structure which is built from structures and pointers. It forms a chain of "nodes" with pointers representing the links of the chain and holding the entire thing together. A linked list can be represented by a diagram like this one:
不錯的參考 C ++
"Creating Linked Lists in C++ What is a linked list? A linked list is a data structure which is built from structures and pointers. It forms a chain of "nodes" with pointers representing the links of the chain and holding the entire thing together. A linked list can be represented by a diagram like this one:"
- Creating Linked Lists in C++ (在「Google 網頁註解」中檢視)
Sorting Records
I am writing a program to sort records using a sorting algorithm of my choice. However before I can get to that I am having trouble reading in each record. Can someone provide some insight. I know that I want to do a linked list for easy insertion rather than an array, I just don't know where I am going wrong with my code. Thanks in advance!!
"I am writing a program to sort records using a sorting algorithm of my choice. However before I can get to that I am having trouble reading in each record. Can someone provide some insight. I know that I want to do a linked list for easy insertion rather than an array, I just don't know where I am going wrong with my code. Thanks in advance!!"
- Sorting Records (在「Google 網頁註解」中檢視)