我在我的C程序中使用sprintf,我正在尝试格式化字符串.
这是我的代码:
sprintf(string, "| %-5%lu | %-9%s | %-9%s | %c | %-4%f |", currentPtr->s.SID, currentPtr->s.lname, currentPtr->s.fname, currentPtr->s.initial, currentPtr->s.GPA);
Run Code Online (Sandbox Code Playgroud)
我一直收到警告:
warning: conversion lacks type at end of format [-Wformat]
Run Code Online (Sandbox Code Playgroud)
为什么我收到这个警告?
编辑:对不起,我应该添加我的结构,以便你们知道我的变量是什么类型.
结构:
typedef struct student {
char lname[ 10 ], initial, fname[ 10 ];
unsigned long SID;
float GPA;
} SREC;
typedef struct node {
SREC s;
struct node *nextPtr;
} Node;
typedef Node *NodePtr;
Run Code Online (Sandbox Code Playgroud)
currentPtr是一个NodePtr
编辑2:解答了感谢!:)