以下内容将在Windows批处理文件中打印当前数据和时间:
CXX=gcc
CXX_FLAGS=-c -O0 -Wall -Wextra
CXX_LFLAGS=-lssl -lcrypto -ldl -liniparser
SOURCES=main.cpp test.cpp ...cpp #add your source files here
OBJECTS=$(SOURCES:.cpp=.o) #takes the .cpp files from the SOURCES var and replaces the .cpp with .o for each
EXEC=yourapp
all: $(SOURCES) $(EXEC)
clean:
rm -f $(OBJECTS)
rm -f $(EXEC)
$(EXEC): $(OBJECTS)
$(CXX) -o $@ $(OBJECTS) $(CXX_LFLAGS) #$@ will be replaced with the content of EXEC, so your applications name
#a build rule for all .cpp files to be compiled to a .o file. % is a placeholder for the actual name of the file
%.o: %.cpp
$(CXX) $(CXX_FLAGS) $< # $< will be replaced with the .cpp file name
我发现了here。
但是,如果放在循环中,初始数据和时间将不断打印,并且不会更新以反映新时间。
如何修改以反映循环中的当前时间和工作?
由于
答案 0 :(得分:0)
将其放置在批处理文件中,否则代码将不起作用。
@echo off
:loop
echo date: %date% | time: %time%
goto loop