База ответов ИНТУИТ

Программирование на языке C в Microsoft Visual Studio 2010

<<- Назад к вопросам

Чему будет равно значение переменной str после выполнения приведенной программы?
union test {  char ch1[5];  char ch2[2];  char ch3[1];};int main(void){	union test t;	char *str;	strcpy(t.ch1, "test");	strcpy(t.ch2, "be");	t.ch3[0] = 'w';	str = t.ch1;	return 0;}

(Отметьте один правильный вариант ответа.)

Варианты ответа
test
best
west
be
we(Верный ответ)
w
Похожие вопросы
Чему будет равно значение переменной str после выполнения приведенной программы?
union test {  char ch1[5];  char ch2[2];  char ch3[1];};int main(void){	union test t;	char *str;	t.ch3[0] = 'w';	strcpy(t.ch2, "be");	strcpy(t.ch1, "test");	t.ch1[2] = '\0';	str = t.ch2;	return 0;}
Чему будет равно значение переменной str после выполнения приведенной программы?
union test {  char ch1[5];  char ch2[2];  char ch3[1];};int main(void){	union test t;	char *str;	strcpy(t.ch1, "test");	t.ch2[0] = 'b';	t.ch3[0] = 'w';	str = t.ch1;	return 0;}
Чему будет равно значение переменной m в результате выполнения приведенной программы?
int main(void){  FILE *fp;  char str[30] = "Lection 11";  int k, l, m;  if((fp=fopen("g:\\test.txt", "wt+"))==NULL) {    printf("Ошибка при открытии файла.\n");    exit(1);  }  k = fwrite(str, sizeof(char), strlen(str)-3, fp);  rewind(fp);  l = fread(str, sizeof(char), sizeof(str)/sizeof(char), fp);   m= l - k;  fclose(fp);  return 0;}
Чему будет равно значение переменной m в результате выполнения приведенной программы?
int main(void){  FILE *fp;  char str[30] = "Lection 11";  int k, l, m;  if((fp=fopen("g:\\test.txt", "wt+"))==NULL) {    printf("Ошибка при открытии файла.\n");    exit(1);  }  k = fwrite(str, sizeof(char), strlen(str)-3, fp);  rewind(fp);  l = fread(str, sizeof(char), sizeof(str)/sizeof(char), fp);   m= k+l;  fclose(fp);  return 0;}
Сколько символов будет прочитано из файла функцией fread() в результате выполнения приведенной программы?
int main(void){  FILE *fp;  char str[30] = "Lection 11";  if((fp=fopen("g:\\test.txt", "wt+"))==NULL) {    printf("Ошибка при открытии файла.\n");    exit(1);  }  fwrite(str, sizeof(char), strlen(str)-3, fp);    rewind(fp);  fread(str, sizeof(char), sizeof(str)/sizeof(char), fp);    fclose(fp);  return 0;}
Чему будет равно значение переменной s после выполнения приведенного фрагмента кода?
int test();int a = 1;int main (void) {	int b, s;	extern int x;	static int c;	int a;	a = 2;	s = test();	return 0;  }int test() {	int t = a;	return t;}
Чему будет равно значение переменной c после выполнения приведенной программы?
int main(void){	struct test {		unsigned int a : 2;		unsigned int b : 8;	};		int c;	struct test t;	t.b = 255;	t.a = 3;	c = t.b | t.a;	printf("c = %d\n", c);	return 0;}	
Чему будет равно значение переменной t.a после выполнения приведенной программы?
int main(void){	struct test {		unsigned int a : 2;		unsigned int b : 8;	};		int c;	struct test t;	t.b = 255;	t.a = t.b & 3;	printf("t.a = %d\n", t.a);	return 0;}	
Чему будет равно значение переменной c после выполнения приведенной программы?
int main(void){	struct test {		unsigned int a : 2;		unsigned int b : 8;	};		int c;	struct test t;	t.b = 255;	t.a = 3;	c = t.b ^ t.a;	printf("c = %d\n", c);	return 0;}	
Задана программа, в которой реализовано три функции: Init - функция инициализации структуры, Print - функция вывода структуры на экран, Modify - функция изменения полей структуры:
typedef struct {	char fio[30];	char phone[20];	int age;} note;note Init(char*, char*, int);void Print(note*);void Modify(note);int main(void){	note n[3], *pn;	char *strName[3] = {"Ivanov I.", "Pertov P.", "Sidorov S."};	char *strPhone[3] = {"12-34-56", "78-90-12", "34-56-78"};	int i, age = 25;	for (i=0; i<3; i++) {		n[i] = Init(strName[i], strPhone[i], age+i);		pn = &n[i];		Print(pn);	}	Modify(n[0]);	pn = &n[0];	Print(pn);	return 0;}note Init(char* f, char* p, int a){	note n, *pn;	pn = &n;	strcpy(pn->fio, f);	strcpy(pn->phone, p);	pn->age = a;	return n;}void Print(note *pn){	printf("\nName: %s", pn->fio);	printf("\nPhone: %s", pn->phone);	printf("\nAge: %d\n", pn->age);}void Modify(note n) {	strcpy(n.fio, "Vasiliev V.");	strcpy(n.phone, "89-01-23");	n.age = 30;}
Какая функция не соответсвует поставленной задаче?