我有一个黑色文字和白色背景的div.在IE9中显示得很好.但是,在打印预览中,白色背景是透明的.适用于Chrome,Firefox和Safari.有任何想法吗?
以下链接显示该页面.显示很好,但地图右下角的白框在打印预览中具有透明背景.
http://www.mycoursewalk.com/course_walk/print/426
谢谢,
缺口,
我最近根据POSIX 1003.1c开始学习pthreads的奇迹.
PThreads可能看起来很复杂,但它们基本上是我们在类中用来创建并行行为的简单线程:https://computing.llnl.gov/tutorials/pthreads/
在我还在学习的时候,我的老师给了我们一个C代码来玩具:
/* Creates two threads, one printing 10000 "a"s, the other printing
10000 "b"s.
Illustrates: thread creation, thread joining. */
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include "pthread.h"
void * process(void * arg)
{
int i;
fprintf(stderr, "Starting process %s\n", (char *) arg);
for (i = 0; i < 100; i++) {
write(1, (char *) arg, 1);
// fprintf(stdout, (char *) arg, 1);
}
return NULL;
}
int main()
{
int retcode;
pthread_t th_a, …Run Code Online (Sandbox Code Playgroud) 在网上:使用printf添加两个数字(不使用任何运算符),如下所示:
main()
{
printf("Summ = %d",add(10,20))
return 0;
}
int add(int x,int y)
{
return printf("%*d%*d",x,' ',y,' ');
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释,这是如何工作的:
return printf("%*d%*d",x,' ',y,' ');
Run Code Online (Sandbox Code Playgroud)
注意:当我称之为"sum"时,这会失败,如下所示:
sum(1,1) or sum(3,-1)
Run Code Online (Sandbox Code Playgroud) 任何人都知道是否可以使用printf打印VARIABLE位数?
以下代码行正好打印2:
printf("%.2lf", x);
Run Code Online (Sandbox Code Playgroud)
但是我要说我有一个变量:
int precision = 2;
Run Code Online (Sandbox Code Playgroud)
有没有办法在printf中使用它来指定位数?
否则我将不得不写一个'switch'或'if'结构.
谢谢
我找到了以下C++代码(评论自己添加):
// frame_name is a char array
// prefix is std::string
// k is a for loop counter
// frames is a std::vector string
sprintf(frameName, "%s_%0*s.bmp", prefix.c_str(), k, frames[k].c_str());
Run Code Online (Sandbox Code Playgroud)
然后我尝试将其翻译为C#
// prefix is string
// k is a for loop counter
// frames is List<string>
string frameName = string.Format("{0}_(what goes in here?).bmp", prefix, k, frames[k]);
Run Code Online (Sandbox Code Playgroud)
基本上,C++格式字符串"%s_%0*s.bmp"的C#等价物是什么?
编辑,@ Mark Byers:
我已经尝试了你的代码并做了一个小测试程序:
static void Main(string[] args)
{
List<string> frames = new List<string>();
frames.Add("blah");
frames.Add("cool");
frames.Add("fsdt");
string prefix = "prefix";
int n = …Run Code Online (Sandbox Code Playgroud) printf("by %1$s on %2$s", 'string1', 'string2');不起作用,而printf('by %1$s on %2$s', 'string1', 'string2');确实起作用.
我实际上正在设计一个Wordpress主题,并且非常密切地遵循原始的二十世纪主题.奇怪的是,我一直在所有以前的printf()语句中使用双引号,没有任何问题.
很抱歉让每个人都讨厌,但这给我带来了一些痛苦.这是代码:
char buf[500];
sprintf(buf,"D:\\Important\\Calibration\\Results\\model_%i.xml",mEstimatingModelID);
Run Code Online (Sandbox Code Playgroud)
mEstimatingModelID是一个整数,当前保持值为0.
很简单,但调试显示这种情况正在发生:
0x0795f630 "n\Results\model_0.xml"
Run Code Online (Sandbox Code Playgroud)
即它缺少字符串的开头.
有任何想法吗?这很简单,但我无法弄清楚.
谢谢!
以下代码导致:
0.000000
10
在这种情况下,“数据”返回了什么?我知道n.data.idata并且n.data.fdata将是正确的用法,我只是好奇为什么整数值在这种情况下有效而浮点值却不起作用
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
union container
{
int idata;
float fdata;
} data;
struct node *next;
} Node;
int main()
{
Node i = {.data.idata = 10};
Node n = {.data.fdata = 10.0};
printf("%f\n", n.data);
printf("%d\n", i.data);
printf("\nExiting program...\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我似乎无法弄清楚为什么有些printf库函数会从libc_nano.a链接到我的代码中,即使我从不使用任何函数printf.它窃取了至少2K宝贵的闪存空间.我能看到的部分_printf_i,_vfprintf_r,_vfiprintf_r在我的链接器映射文件等.
我试过了
这些都不会使符号从地图文件中消失.
我的gcc选项:
CFLAGS = -Og -Wall -g3 -Wdouble-promotion -mcpu=cortex-m0 -mthumb -fmessage-length=0 -ffunction-sections -mfloat-abi=soft -DUSE_HAL_DRIVER
LFLAGS = -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -Wl,--gc-sections
Run Code Online (Sandbox Code Playgroud)
arm-none-eabi-gcc.exe(适用于ARM嵌入式处理器的GNU工具)5.2.1 20151202(re lease)[ARM/embedded-5-branch revision 231848] Copyright(C)2015 Free Software Foundation,Inc.这是免费的软件; 查看复制条件的来源.没有保修; 甚至不适用于适销性或特定用途的适用性.
首先,他们为什么要联系起来?有没有办法排除它们?
我在玩C; 看一下这个:
#include <stdio.h>
#include <stdlib.h>
void main() {
printf("%d\n", 1.5);
printf("%f", 0);
}
Run Code Online (Sandbox Code Playgroud)
我期待输出:
0
0.000000
Run Code Online (Sandbox Code Playgroud)
但它打印:
0
1.500000
Run Code Online (Sandbox Code Playgroud)
第一次printf()通过1.5第二次printf()吗?
PS:我知道(%d对于整数,%f浮标).正如我所提到的,我只是在搞乱代码.
PS2:我正在使用DevC++和Code :: Blocks.