Convert strings to longs

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago
parent cc44daa055
commit 625972ce92
  1. 2
      C/scripts/build.sh
  2. 2
      C/scripts/md5
  3. 24
      main.c
  4. BIN
      memovr
  5. 4
      sig
  6. 2
      utils/main.sh
  7. 2
      utils/md5

@ -2,6 +2,6 @@
#C
printf "Running program...\n\n\n"
if gcc $(find . -type f -name "*.c") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then
./${PROJECT_NAME}
./${PROJECT_NAME} "$@"
fi
printf "\n\n"

@ -1,2 +1,2 @@
build.sh:dbb1880f6b747ec208d6f277c0be61c2 -
build.sh:fcbd8c14fe2a608d11166cf5aa7dba02 -
commit.sh:89783d2e6a165aa9612c79cfbd804a35 -

@ -1,5 +1,27 @@
#include <stdio.h>
#include <sys/uio.h>
unsigned long strToLong(char*str) {
int counter=0;
char c;
unsigned long val=0;
while ((c=str[counter++])!='\0') {
val*=10;
val+=c-'0';
}
return val;
}
int main(int argc,char**argv) {
printf("Hello World!");
unsigned int pid;
unsigned long addr;
unsigned long val;
if (argc<3) {
printf("3 arguments required! Only %d specified.",argc);
} else {
for (int i=1;i<argc;i++) {
printf("\nArg %d: %lu",i+1,strToLong(argv[i]));
}
}
printf("\nHello World!");
}

BIN
memovr

Binary file not shown.

4
sig

@ -2,8 +2,8 @@ export AUTO_UPDATE=true
source utils/define.sh
define PROJECT_NAME "CProjectTemplate"
define CUSTOM_PARAMS "-lncurses"
define PROJECT_NAME "memovr"
define CUSTOM_PARAMS ""
define LANGUAGE "C"
source utils/main.sh

@ -25,4 +25,4 @@ if [ -z "$1" ]
exit
fi
./$LANGUAGE/scripts/$1.sh "${*:2}"
./$LANGUAGE/scripts/$1.sh "${@:2}"

@ -1,4 +1,4 @@
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 -
main.sh:d3d1bd0b56d8114eb7479964227f8576 -
main.sh:4e6e9f0650ec790ce2c4364db94f0caa -
search.sh:81d08f5ff48e8a44b5f68387d426da05 -
.updateDirectories:fa5e95db12be22ae8aed7ecbc560e38c -

Loading…
Cancel
Save