first commit

This commit is contained in:
2023-06-02 02:41:24 +08:00
parent 6b95ca5582
commit edc6966b9d
20 changed files with 309 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.c
+7
View File
@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
@@ -0,0 +1,6 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.c
+28
View File
@@ -0,0 +1,28 @@
#include <stdio.h>
int main(int argc, char *argv[])
{
// 定义一个char类型的变量并赋值,输出字符使用c%
char a = 'w';
printf("a = %c\n",a);
// 定义一个short类型的变量并赋值
short b = 100;
printf("b = %d\n",b);
// 定义一个int类型的变量并赋值,输出int类型变量的值使用%d
int c = 9999;
printf("c = %d\n",c);
// 定义一个long类型的变量并赋值,输出long类型变量的值使用%ld
long d = 2342341;
printf("d = %ld\n",d);
float e = 3.1415926;
printf("e = %f\n",e);
double f = 3234.234214342345;
printf("f = %lf\n",f);
return 0;
}
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/05_printf.iml" filepath="$PROJECT_DIR$/.idea/05_printf.iml" />
</modules>
</component>
</project>
+50
View File
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="31f10055-069d-473b-9478-0309bc257748" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="ProjectId" id="2QQgIoSTflB0TzMXNpGO2ORQeSd" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"WebServerToolWindowFactoryState": "false",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"last_opened_file_path": "D:/GitHome/QianFeng/C_lang/05_printf",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="31f10055-069d-473b-9478-0309bc257748" name="Changes" comment="" />
<created>1685291143580</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1685291143580</updated>
<workItem from="1685291144185" duration="50000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.c
+46
View File
@@ -0,0 +1,46 @@
#include <stdio.h>
int main(int argc, char *argv[])
{
int a = 100;
printf("a = %d\n",a);
printf("a = %o\n",a); // 八进制输出
printf("a = %#o\n",a); // %#o 可以输出八进制数的前导符
printf("a = %x\n",a); // 十六进制输出
printf("a = %#x\n",a);
// 输出浮点型数据,float使用%f,double使用%lf
float b = 3.1415926;
double c = 2345.2345;
printf("b = %f\n",b);
printf("c = %lf\n",c);
// 输出字符,使用%c使出字符,使用%d可以输出字符的ascii码值
char d = 'y';
printf("d = %c %d\n",d,d);
char e[] = "hello world";
printf("e = %s\n",e);
// 输出地址,使用%p
int f = 999;
// &:取一个变量的地址,一般地址用十六进制标识
printf("&p = %#p\n", &f); // 获取当前变量的地址用 %p
int m = 456;
printf("%d%d\n", m, m);
printf("%5d%5d\n", m, m);
// %05d:输出的宽度为5,右对齐,如果实际数据的宽度小于5,则左边位置补0
printf("%05d%05d\n", m, m);
//%-5d:输出的宽度为5,左对齐,如果实际数据的宽度小于5,则右边补空格
printf("%-5d%-5d\n", m, m);
float n = 3.678;
printf("n = %f\n", n);
//%.2f:小数点后保留两位,并且可以四舍五入
printf("n = %.2f\n", n);
}