Commit bdb576d6 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add some tests

parent 3db9b2c6
#include <string.h>
// http://www.cpptalk.net/invalid-conversion-from-char-to-const-char-vt13716.html
main(int argc, char **argv)
{
char **t1;
const char **t2;
const char **t3 = new const char *[10]; // t3 - 土佑勺 账邻猎盘攀 瘟 const char*
char * const *t4 = new char*[10]; // t4 - 讼斡粤卧钨 土佑勺 账邻猎盘攀 瘟 char*
const char * const * t5;
t1 = argv;
// t2 = argv; // error: invalid conversion from 'char**' to 'const char**'
t2 = (const char**) argv;
t4 = argv;
t3[0] = argv[0];
// t4[0] = argv[0]; // error: assignment of read-only location '* t4'
t3[0] = new char[100];
//strcpy(t3[0],"text"); // error: invalid conversion from 'const char*' to 'char*'
strcpy(t4[0],"text"); // error: invalid conversion from 'const char*' to 'char*'
t3[0] = "test";
// t4[0] = "test"; // error: assignment of read-only location '* t4', warning: deprecated conversion from string constant to 'char*'
t5 = argv;
t5 = t3;
t5 = t4;
}
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
string str;
getline(cin, str);
cout << "size of str=" << str.size() << ", strlen=" << strlen(str.c_str()) << endl;
}
#include <stdio.h>
int main()
{
int a = 5;
int b = -5 ;
unsigned int c = 5;
unsigned int d = -5 ;
int *e = (int*)&d;
if (a < b)
printf("a<b\n");
if ( c < d)
printf("c<d\n");
printf("%x\n", *e);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment