首页 \ 问答 \ C printf整数类型U32(C printf integer type U32)

C printf整数类型U32(C printf integer type U32)

我有十六进制值0x5a800000000b ,我正在尝试在C中获取printf语句将其打印到控制台。

到目前为止(因为我在C中没用)我可以使用以下语法来打印'b':

printf("Hex value%x\n", value);

该值存储在整数类型U32中,但在尝试%llx,%lx的所有不同组合后,我只是不断收到编译器警告。

我猜我的printf语法错误,但我似乎无法找到合适的%选项,有人可以帮助我吗?

谢谢


I have the hex value 0x5a800000000b and I'm trying to get a printf statement in C to print it to the console.

So far (because I'm useless in C) I'm able to get the 'b' to print, using the syntax:

printf("Hex value%x\n", value);

The value is stored in an integer type U32, but after trying all different combinations of %llx, %lx, I just keep getting compiler warnings.

I'm guessing that I'm getting the printf syntax wrong, but I can't seem to find the right % option, can someone help me out?

Thanks


原文:https://stackoverflow.com/questions/14356304
更新时间:2024-01-13 08:01

最满意答案

请尝试以下方法:

set.seed(1234)
# initialize array, giving dimensions
myArray <- array(0, dim=c(2,2,3))

for(i in 1:3){
  rnormRdn <- matrix(rnorm(n = 4), nrow = 2, ncol = 2)
  print("New random matrix that should be appended is:")
  print(rnormRdn)
  myArray[,,i] <- rnormRdn
  print("New random matrix not correctly apended on after first iteration:")
  print(myArray)
}

如果你提前知道数组的大小,就像在第二行中那样为它预分配空间要高效得多。


Try the following:

set.seed(1234)
# initialize array, giving dimensions
myArray <- array(0, dim=c(2,2,3))

for(i in 1:3){
  rnormRdn <- matrix(rnorm(n = 4), nrow = 2, ncol = 2)
  print("New random matrix that should be appended is:")
  print(rnormRdn)
  myArray[,,i] <- rnormRdn
  print("New random matrix not correctly apended on after first iteration:")
  print(myArray)
}

If you know the size of the array ahead of time it is much more efficient to preallocate the space for it as I did in the second line.

相关问答

更多
  • 请尝试以下方法: set.seed(1234) # initialize array, giving dimensions myArray <- array(0, dim=c(2,2,3)) for(i in 1:3){ rnormRdn <- matrix(rnorm(n = 4), nrow = 2, ncol = 2) print("New random matrix that should be appended is:") print(rnormRdn) myArray[,,i] ...
  • 您没有在每个循环之间重新声明列表(Python列表而不是数组)。 您需要在其中一个循环内移动您的details_array的创建,以便将其重新创建为空。 你可能会看起来像这样: for day in life.days: details_array = [] for span in day.spans: 这种方式对于每天的每个新迭代,您将有一个新的空列表。 You aren't redeclaring your list (Python has lists not arrays) in b ...
  • 您需要传递$filter_value作为参考(使用前导& )而不是副本。 foreach($results['filters'] as $filter_key => &$filter_value) { $filter_value[] = array('name' => 'All'); } 文件 : 为了能够直接修改循环中的数组元素,在$ value之前加上&。 在这种情况下,该值将通过引用分配。 You need to pass the $filter_value as reference (wi ...
  • 我通常使用lapply这样的用例。 这样,您就不会遇到延迟评估的问题。 library(shiny) ui <- fluidPage( mainPanel( uiOutput("tables") ) ) server <- function(input, output) { output$tables <- renderUI({ data=array(rnorm(150),c(10,5,3)) tfc = function(m){renderTable({m})} ...
  • 以下是使用dplyr做到这一点的一种方法: basket <- read.table(text="BSKT STOCK Units Date A AAPL 10 15/05/17 A V 25 15/05/17 B MFC 5 15/05/17 B GOOG 30 15/05/17 C AAPL 30 17/05/17 D AAPL ...
  • 我们可以通过在vector上执行^直接得到这个 (1:10)^2 #[1] 1 4 9 16 25 36 49 64 81 100 如果你需要一个list ,只需用as.list包装它 as.list((1:10)^2) We can get this directly by doing the ^ on the vector (1:10)^2 #[1] 1 4 9 16 25 36 49 64 81 100 If you need a lis ...
  • 当你需要在函数中使用中间值时,嵌套def的使用并不是真正的方法,这就是let表单的用途。 另请注意, def会创建一个顶级var,因此即使在make-query函数返回之后,您仍然会在声明该函数的命名空间中放置一个tmpa var。 您发布的函数具有命令式样式,因为它使用doseq ( 根据定义用于副作用)并在循环的每次迭代中更改tmpa var的值。 一种功能方法是reduce键值对,并通过在每次调用reduce函数时将键和值连接到查询字符串来构建结果。 以下是如何实现这一目标的示例: (def char ...
  • SIN_FM5 <- data.frame(Combination = sample(1:10, 100, repl=TRUE), MONTANT_PAIEMENT=rnorm(100)) bySIN <- by(SIN_FM5, list(SIN_FM5[['Combination']]), FUN= function(subd) { data.frame(counts = nrow(subd), meanMont = mean(subd$MONT ...
  • 这是因为您尝试将不存在的值count[l]到1 。 你从count<-0 ,所以count是长度为1。 没有count[2] ,因此对count[2]的引用返回NA 。 然后(假设你的循环中l = 2 ), NA + l返回NA 。 如果初始化count<-rep(0,length(positions))这个特殊问题就会消失。 同时,您可以将操作矢量化很多。 我相信你可以用。取代k-loop count[l] <- sum(y$feature[a:b]==x$feature[l]) 举个例子。 It' ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。