当我设置autofocus="autofocus"一个输入元素,然后在Firefox中,当页面加载时,它会在没有应用CSS的情况下显示一瞬间.(例如,内容不居中,标题以默认字体等呈现)
如果我删除自动对焦,页面会正常加载并在准备就绪时显示.
autofocus在Firefox中使用该功能时,有没有办法让页面正常加载?
我试图将strnstr函数实现为C(strstr,但它会检查长度),由于某种原因它不起作用(输出始终为no):
#include <stdio.h>
char *searchingFor = "stackdummy";
char *in = "la da\ndoo a da\nnow here comes the stack\nok there it was.\n";
char *strnstr(char *s1, char *s2, int length) {
if(s1 == NULL || s2 == NULL) return NULL;
printf("searching \n\n\"%s\"\n for %.*s\n", s1, length, s2);
char *ss1 = malloc(strlen(s1) + 1);
strcpy(ss1, s1);
char *ss2 = malloc(length + 1);
strncpy(ss2, s2, length);
char *result = strstr(ss1, ss2);
free(ss1);
free(ss2);
return result;
}
int main(void) {
printf("found: %s\n", strnstr(in, searchingFor, 5) …Run Code Online (Sandbox Code Playgroud) 我希望Visual Basic能够在目录"C:\ projectTest \"上运行"make"命令.
我试着用这个:
Dim output As String = String.Empty
Using Process As New Process
Process.StartInfo = New ProcessStartInfo("cmd")
Process.StartInfo.WorkingDirectory = "C:\projectTest\"
Process.StartInfo.UseShellExecute = False
Process.StartInfo.CreateNoWindow = True
Process.StartInfo.RedirectStandardInput = True
Process.StartInfo.RedirectStandardOutput = True
Process.StartInfo.RedirectStandardError = True
Process.Start()
Process.BeginOutputReadLine()
AddHandler Process.OutputDataReceived,
_
Sub(processSender As Object, lineOut As DataReceivedEventArgs)
output += lineOut.Data + vbCrLf
End Sub
Using InputStream As System.IO.StreamWriter = Process.StandardInput
InputStream.AutoFlush = False
InputStream.WriteLine("make")
End Using
Do
Application.DoEvents()
Loop Until Process.HasExited
End Using
Run Code Online (Sandbox Code Playgroud)
此代码能够捕获控制台的"gcc ..."部分(来自Makefile),但不会捕获错误(如果我手动打开cmd并在该目录上运行make,则会弹出错误).
如何捕获出现的所有内容,包括错误?
使用plain C,(不是C++/C#/ Objective-C)如何在Windows中获得屏幕分辨率?
我的编译器是MingW(不确定是否相关).我在网上找到的所有解决方案都是针对C++或其他一些C变种.
我有这个代码:
#include <stdio.h>
#include "SDL/SDL.h"
SDL_Surface *screen = NULL;
int main(int argc, char* args[]) {
SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
SDL_Delay(2000);
SDL_Quit();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我使用这个命令行编译(Mingw 是我的编译器):
gcc source.c -o bin.exe -lmingw32 -lSDLmain -lSDL
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序时,虽然出现了一个漂亮的图形框,但也出现了一个丑陋的控制台窗口。如何删除它,只留下一个真正的图形应用程序?
另外,如何将鼠标恢复为默认值?当我将鼠标悬停在窗口上时,它似乎正在使用这个丑陋的自定义鼠标。我在这里读到我必须自己做这个:
http://www.gamedev.net/topic/297710-change-mouse-cursor-sdl/
这是真的吗?是否没有内置功能可以禁用自定义黑色光标?
我想将一个整数舍i入到最接近的 4 倍数。
例如:
0 -> 0
1 -> 0
2 -> 0
3 -> 0
4 -> 4
5 -> 4
6 -> 4
7 -> 4
8 -> 8
9 -> 8
Run Code Online (Sandbox Code Playgroud)
我这样做的明显方法是:
i = (i / 4) * 4;
Run Code Online (Sandbox Code Playgroud)
但是我因为使用它而受到批评,因为据说它不清楚,并且看起来像一个错误。
我知道明显的替代方案,按位移位:
i = (i >> 2) << 2;
Run Code Online (Sandbox Code Playgroud)
但我随后意识到有一种完全不同的方法:
(i | 3) - 3
Run Code Online (Sandbox Code Playgroud)
示例程序:
#include <stdio.h>
int main(void) {
int i;
for(i = 0; i < 4*4; i++) {
printf("%d %d %d %d\n", i, …Run Code Online (Sandbox Code Playgroud) 如何char*在不创建数组并初始化数组的情况下将数组作为参数传递?
此代码有效(创建初始化代码):
char *messages[] = {"Zero", "One", "Two", "Three"};
printf("%s", messages[1]);
Run Code Online (Sandbox Code Playgroud)
但如果你这样传递它就不会起作用:
#include <stdio.h>
void printElement1(char *messages[]) {
printf("%s", messages[1]);
}
int main(void) {
printElement1({"Zero", "One", "Two", "Three"});
return 1;
}
Run Code Online (Sandbox Code Playgroud)
我不能使用a va_list,该函数接受一个char*数组就是这样.