标签:
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[])
{
char cl = ‘A‘;
cout << ‘W‘ << ‘ ‘;
cout << cl << endl;
cout << "this is a test." << endl;
cout << "----------" << endl;
char *name="howareyou";
char ch;
FILE *fp;
if((fp=fopen("./bs.txt","r"))==NULL){
cout << "err"<<endl;
}
ch=fgetc(fp);
while(ch!=EOF)
{
if(ch==‘\n‘)
cout<< "a new line"<<endl;
putchar(ch);
ch=fgetc(fp);
}
printf("I need %s %d",name,5);
string path="\\home";
cout << path;
return 0;
}
char* readline(FILE* f)
{
char* line = (char*) calloc(1, sizeof(char) );;
char c;
int len = 0;
while ( (c = fgetc(f) ) != EOF && c != ‘/n‘)
{
line = (char*) realloc(line, sizeof(char) * (len + 2) );
line[len++] = c;
line[len] = ‘/0‘;
}
return line;
}
标签:
原文地址:http://www.cnblogs.com/hualiu0/p/5834494.html