#include "stdio.h"
int main(void){
char a[]="1234567890",b[]="abcdefg"
printf("不添换行符:\n%s%s\n",a,b)
printf("不添换行符:\n%s\n%s\n",a,b)
return 0
}
c 语言程序。假定在 s[3] 这里插入 换行符,可以把这个点以后的字符串后推一格,再填入换行符。#include <stdio.h>
int main(){
char s[20]="ABCDEFGHIJK"
int n=3 //insert location
int i
strcpy(s+n+1,&s[n]) // 后推一格
s[n]='\n' // 填入换行符
printf("%s",s)
return 0
}
输出:ABC
DDFGHHJK
字符串加回车换行TAB符号所有字符在下面的类中:
cl_abap_char_utilities=>horizontal_tab — 09
cl_abap_char_utilities=>CR_LF ———- 0D0A
cl_abap_char_utilities=>VERTICAL_TAB — 0B
cl_abap_char_utilities=>NEWLINE —- 0A
cl_abap_char_utilities=>FORM_FEED —- 0C
cl_abap_char_utilities=>BACKSPACE — 08
如果是要单独取得回车或者换行(不是回车加换行),可以采用:
cl_abap_char_utilities=>CR_LF(1)
cl_abap_char_utilities=>CR_LF 1(1)
从EXCEl文件中传上的文件的回车符就是cl_abap_char_utilities=>CR_LF 1(1)
DATA: crlf(2) TYPE c.
crlf = cl_ABAP_char_utilities=>cr_lf. "换行符
在字符串中加入回车换行或TAB字符,在其他语言可以使用$13$10的ASCII码进行插入.而在abap里却出错,为了解决此问题,请使用sap的类CL_ABAP_CHAR_UTILITIES.
CL_ABAP_CHAR_UTILITIES中有字符常量:如:CR_LF,HORIZONTAL_TAB,NEWLINE等等.
例:
DATA: crlf(2) TYPE c.
DATA: l_html(4096) TYPE C.
crlf = cl_ABAP_char_utilities=>cr_lf.
CONCATENATE l_html crlf '_FUNCTION'
'30'
'WWW_GET_REPORT' '>' INTO l_html.
----
调用方法产生文件路径对话框
DATA: p_file LIKE rlgrap-filename.
FIELD-SYMBOLS <fs>TYPE file_table.
FIELD-SYMBOLS <f>.
DATA: f_table TYPE filetable.
DATA: rc TYPE i.
DATA: user_action TYPE i.
DATA: l_index TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = '请选择要汇入的文件'
file_filter = 'Excel files (*.XLS)|*.XLS'
initial_directory = 'D:\'
CHANGING
file_table = f_table
rc = rc
user_action = user_action
EXCEPTIONS
cntl_error = 1
file_open_dialog_failed = 2
error_no_gui = 3.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
CLEAR p_file.
READ TABLE f_table ASSIGNING <fs>INDEX 1.
IF sy-subrc = 0.
p_file = <fs>-filename.
ENDIF.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)