小编Arm*_*gdy的帖子

如果我在另一个文件中声明另一个具有相同名称的变量会发生什么?

我已int x文件1中声明并且错误地在文件2中声明了另一个char具有相同名称的类型变量,并且我等待编译器或链接器给我一个错误,但是没有显示错误.当我使用调试器时,我看到它被转换为,是真的吗?!这里到底发生了什么?!xint xchar x

在我的代码上显示此修改:

文件一

#include <stdio.h>

int x = 50;  /** declare global variable called
                           x **/
int main()
{
    print();
    printf("      global in file one = %d",x);  /** Modification is just here **/
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

文件二

char x;   

void print(void)
{

    x = 100;
    printf("global in file two = %d ",x);
    return;

}
Run Code Online (Sandbox Code Playgroud)

我的预期结果是= 文件2中的全局=文件1中的100全局= 50

结果是:文件2中的全局=文件1中的100全局= 100

当我使用调试器时,我看到int x转换为char …

c

4
推荐指数
1
解决办法
123
查看次数

为什么我不能在for循环中使用x + 1?

我正在处理该代码,我试图使用x + 1而不是++x结果是无限循环并且在屏幕上打印了零.

这是代码:

#include <stdio.h>
int main(void){
  int x;
  for(x = 0; x <= 100; x + 1) //instead of ++x
    printf("%d\t",x);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我想知道这个动作.....为什么编译器没有产生这样的错误,,,,实际发生了什么?!! 并被x++视为x += 1?!

c

3
推荐指数
3
解决办法
437
查看次数

该代码中的错误是什么?

这段代码中的错误是什么?!!

提示:sp_to_dash()以下程序中的函数在其字符串参数中为每个空格打印一个破折号.也就是说,字符串"this is a test"将打印为"this-is-a-test".

#include <stdio.h>

void sp_to_dash( char *str);

int main(void)
{    
  sp_to_dash("this is a test");

  return 0;    
}

void sp_to_dash( char *str)    
{    
  while(*str) {    
  if(*str==' ' ) *str = '-';    
  printf("%c", *str);    
  str++;    
  }    
}
Run Code Online (Sandbox Code Playgroud)

c c++ string

1
推荐指数
1
解决办法
171
查看次数

使用XAMPP服务器在ubuntu 12.04 LTS上安装Phalcon

我在Ubuntu 12.04 LTS上安装Phalcon框架时遇到问题

我按照本页中列出的说明进行操作

它说你必须在php.ini中添加扩展名

当我在我的终端上制作"locate php.ini"时,出现了5个目录,我把扩展名放在"extension=phalcon.so"上面三个目录中(参见附图).

在此输入图像描述

它直到现在才起作用,因为当我phpinfo()在localhost网页中打开时,phalcon不会出现.

顺便说一句我使用xampp服务器

有任何想法吗 ?!

php linux xampp ubuntu-12.04 phalcon

1
推荐指数
1
解决办法
4422
查看次数

标签 统计

c ×3

c++ ×1

linux ×1

phalcon ×1

php ×1

string ×1

ubuntu-12.04 ×1

xampp ×1