小编fud*_*din的帖子

在程序的一半之后,它变成了回文

我自己做了strrev功能.虽然编译它说func xstrrev()中的代码没有效果.我还想知道,在为分配制作内置函数的副本时,我们可以使用内置函数(其他)吗?因为我在其中使用了strlen().

#include<stdio.h>
#include<conio.h>
#include<string.h>
void xstrrev(char str[]);
void main(void)
{
 char str[30];
 printf("Enter a string:");
 gets(str);
 xstrrev(str);
 printf("\n%s",str);
 getch();
}
void xstrrev(char str[])
{
int i,x;
x=strlen(str);
for(i=0;;i++)
 {

  if(str[i]=='\0')
  {
   break;
  }

str[x-i]=str[i];

 }
}
Run Code Online (Sandbox Code Playgroud)

c

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

不能通过预处理器指令将小写转换为大写字符串

我做了一个程序,将小写字母转换为大写字母.我知道如何通过预处理程序指令将字符串转换为大写字母,但我不知道如何为字符串做.

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#define UPPER([])  ([]-32)
void fstring_convert(char string[]);
void main(void)
{
char string[40];
printf("Enter a string:");
gets(string);
fstring_convert(string);
printf("%s",string);
getch();
}

void fstring_convert(char string[])
{
    int i;
 for(i=0; ;i++)
 {
    if(string[i]==' ')
    {
        string[i]=string[i+1];
    }
    if(isdigit(string[i]))
    {
    string[i]+=1;
    }
    UPPER('string[i]');
    if(string[i]=='\0')
    break;
 }

}
Run Code Online (Sandbox Code Playgroud)

c

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

关于静态变量的混淆

我对静态整数的概念感到困惑.当我在main函数中初始化一个静态整数时

static int i;
Run Code Online (Sandbox Code Playgroud)

现在,静态整数被赋值为0.现在下一步:

i++;
Run Code Online (Sandbox Code Playgroud)

我变成了1.

现在程序终止了.我想知道在下一次运行中会产生什么程序.此外,如果整个程序关闭会发生什么?我明白第一行是静态int i; 因此,下次运行该函数时的下一个值应保留i先前运行时的值.如果是这样,变量静态的优势是什么?变量是否有时间限制,还是可以永久存储?如果我再次运行该功能会有什么价值?

c static

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

请帮助制作strstr()

我已经创建了strstr()函数,但程序没有给出任何输出,只是一个空白的屏幕.请看一下代码.

#include<stdio.h>
#include<conio.h>

    const char* mystrstr(const char *str1, const char *str2);
    int main()
    {
        const char *str1="chal bhai nikal";
        const char *str2="nikal",*result;
        result=mystrstr(str1,str2);
        printf("found at %d location",(int*)*result);
        getch();
        return 0;


    }
    const char * mystrstr(const char *s1, const char *s2)
    {
        int i,j,k,len2,count=0;
        char *p;
        for(len2=0;*s2!='\0';len2++);//len2 becomes the length of s2
        for(i=0,count=0;*s1!='\0';i++)
        {
            if(*(s1+i)==*s2)
            {
                for(j=i,k=0;*s2!='\0';j++,k++)
                {
                    if(*(s1+j)==*(s2+i))
                    count++;
                    if(count==len2)
                    {
                        p=(char*)malloc(sizeof(char*));
                        *p='i';
                    return p;
                    }
                }

            }

        }
        return NULL;
    }
Run Code Online (Sandbox Code Playgroud)

c

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

首先评估表达式的哪一侧?

表达式的右侧是先评估还是左侧评估?

void main ()
{
    int i = 0 , a[3] ;
    a[i] = i++;
    printf ("%d",a[i]) ;
}
Run Code Online (Sandbox Code Playgroud)

c operator-precedence

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

溢出产品的整数

在下面的代码中,prod的值不是9,000,000; 它获得了垃圾值.为什么我们需要num1和num2为long类型?

#include <stdio.h>
int main()
{
    int num1 = 3000, num2 = 3000;
    long int prod = num1 * num2;
    printf("%ld\n", prod);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c overflow

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

逗号运算符的局限性

我已经阅读了这个问题,我想补充说,使用逗号运算符无法完成的事情是什么.这让我很困惑,因为我能做到这一点:

int arr[3];
arr[0]=1,arr[1]=2,arr[2]=3;
Run Code Online (Sandbox Code Playgroud)

但当我这样做时:

int arr[3],arr[0]=1,arr[1]=2,arr[2]=3;
Run Code Online (Sandbox Code Playgroud)

它给了我一个编译器错误.

我想问一下逗号运算符在实际操作中的局限性是什么?

c c++ comma-operator

2
推荐指数
2
解决办法
614
查看次数

如何横向划分网页?

我正在学习HTML.我正在读书中的<div>标签.我理解它如何将网站分成垂直部分,但我也看到了人们<div>在侧边栏使用标签的例子.<div>标签如何水平工作?

html

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

无法在同一行显示列表和h1标记


我正在尝试制作一个带有菜单列表和徽标的网页.在下面的代码中,每当我尝试将它们并排放置时,其中一个向下移动到页面上.我想要列表和标题并排.这是代码,

<!DOCTYPE html>
<html dir="ltr" lang="en-UK"> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Fahad | Just another web designer</title>
        <!--Styling Starts-->
    </script> 
       <style type="text/css"> 
            <link href='http://fonts.googleapis.com/css?family=Chewy&v1' rel='stylesheet'               type='text/css'>
            h1 { font-family: 'Chewy', arial, serif;
             }
             h1 {
                 font-size:45px; 
                 padding-top:70px;
                 padding-left:350px;
             }
            .menu 
            {
                padding:0;
                margin-left:0;  
                height:200px;
                width:300px;
            }
              .menu ul
             {
                padding-left:200px;
                padding-top:45px;
                font:Verdana, Geneva, sans-serif;
                list-style-type:none;
                text-decoration:none;
                color:#666;
              }
              .container
              {
                color:#666; 
              }
              a:link
              {
                 color:#666;
              }
              a:hover
              {
                 color:#333;
              }
              a:active
              {
                color:#666;
              }

     </style>

    </head>
    <body>
        <div class="container"> …
Run Code Online (Sandbox Code Playgroud)

css html5

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

条件运算符中的返回值

我试图通过使用条件运算符来返回值true或false,具体取决于条件,但是我收到了错误.这是我的代码,

bool isEmpty()
{
    int listSize = Node::size();
    listSize > 0 ? return (true) : return (false);
    return false;
}
Run Code Online (Sandbox Code Playgroud)

这是错误,

error C2107: illegal index, indirection not allowed
Run Code Online (Sandbox Code Playgroud)

现在我被困在这里.我不明白这一点.我认为它应该是正确的.请指导我.谢谢

c c++ conditional-operator

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