Skip to main content
added 220 characters in body
Source Link
Cliff B
  • 69.3k
  • 4
  • 33
  • 56
#include <stdio.h>

#include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h>

int main(int argc, string argv[]) { if (argc == 2) { for (int i = 0, n = strlen(argv[1]); i < n; i++) {

#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>


int main(int argc, string argv[])
{
  if (argc == 2) {
    for (int i = 0, n = strlen(argv[1]); i < n; i++) { 


       if (i) {
         printf("%s\n", argv[i]);
       }
    }
    return 0;

  } else if (argc > 2) {
    printf("%s", "Usage: ./caesar key \n");

  } else {
    printf("%s", "Usage: ./caesar key\n");

  }

} else if (argc > 2) { printf("%s", "Usage: ./caesar key \n");

} else { printf("%s", "Usage: ./caesar key\n");

}

Command Line Output:

$ ./caesar 3uhhhlyffx5bp953azmk976rrctfuuu
3uhhhlyffx5bp953azmk976rrctfuuu 
(null) 
LC_ALL=C.UTF-8 
SSH_CONNECTION=192.168.100.119 47830 192.168.151.248 22 
ISOUTPUTPANE=0 
FLASK_APP=application.py 
LANG=C.UTF-8 
DISPLAY=:0 
EDITOR=nano 
NODE_PATH=/home/ubuntu/.c9/node_modules 
GEM_HOME=/home/ubuntu/.gem 
JAVA_HOME=/opt/jdk-12.0.1 
FLASK_DEBUG=0 
C9_PID=9c83620857724cd7bc928021c3765a39 
CFLAGS=-ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow 
S_COLORS=auto 
NODE_ENV=dev 
CLASSPATH=.:/usr/share/java/cs50.jar 
CC=clang 
FLASK_ENV=development 
USER=ubuntu 
C9_USER=studentRole 
APPLICATION_ENV=dev 
PWD=/home/ubuntu/pset2/caesar 
CHECK50_WORKERS=1 
HOME=/home/ubuntu 
LC_CTYPE=C.UTF-8 
C9_HOSTNAME=6c2d1f21-c253-4199-8cad-61c19b30d4f4-ide.cs50.xyz 
SSH_CLIENT=192.168.100.119 47830 22 
TMUX=/tmp/tmux-1000/cloud92.2,4585,0 

3uhhhlyffx5bp953azmk976rrctfuuu (null) LC_ALL=C.UTF-8 SSH_CONNECTION=192.168.100.119 47830 192.168.151.248 22 ISOUTPUTPANE=0 FLASK_APP=application.py LANG=C.UTF-8 DISPLAY=:0 EDITOR=nano NODE_PATH=/home/ubuntu/.c9/node_modules GEM_HOME=/home/ubuntu/.gem JAVA_HOME=/opt/jdk-12.0.1 FLASK_DEBUG=0 C9_PID=9c83620857724cd7bc928021c3765a39 CFLAGS=-ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow S_COLORS=auto NODE_ENV=dev CLASSPATH=.:/usr/share/java/cs50.jar CC=clang FLASK_ENV=development USER=ubuntu C9_USER=studentRole APPLICATION_ENV=dev PWD=/home/ubuntu/pset2/caesar CHECK50_WORKERS=1 HOME=/home/ubuntu LC_CTYPE=C.UTF-8 C9_HOSTNAME=6c2d1f21-c253-4199-8cad-61c19b30d4f4-ide.cs50.xyz SSH_CLIENT=192.168.100.119 47830 22 TMUX=/tmp/tmux-1000/cloud92.2,4585,0

#include <stdio.h>

#include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h>

int main(int argc, string argv[]) { if (argc == 2) { for (int i = 0, n = strlen(argv[1]); i < n; i++) {

   if (i) {
     printf("%s\n", argv[i]);
   }
}
return 0;

} else if (argc > 2) { printf("%s", "Usage: ./caesar key \n");

} else { printf("%s", "Usage: ./caesar key\n");

}

Command Line Output:

$ ./caesar 3uhhhlyffx5bp953azmk976rrctfuuu

3uhhhlyffx5bp953azmk976rrctfuuu (null) LC_ALL=C.UTF-8 SSH_CONNECTION=192.168.100.119 47830 192.168.151.248 22 ISOUTPUTPANE=0 FLASK_APP=application.py LANG=C.UTF-8 DISPLAY=:0 EDITOR=nano NODE_PATH=/home/ubuntu/.c9/node_modules GEM_HOME=/home/ubuntu/.gem JAVA_HOME=/opt/jdk-12.0.1 FLASK_DEBUG=0 C9_PID=9c83620857724cd7bc928021c3765a39 CFLAGS=-ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow S_COLORS=auto NODE_ENV=dev CLASSPATH=.:/usr/share/java/cs50.jar CC=clang FLASK_ENV=development USER=ubuntu C9_USER=studentRole APPLICATION_ENV=dev PWD=/home/ubuntu/pset2/caesar CHECK50_WORKERS=1 HOME=/home/ubuntu LC_CTYPE=C.UTF-8 C9_HOSTNAME=6c2d1f21-c253-4199-8cad-61c19b30d4f4-ide.cs50.xyz SSH_CLIENT=192.168.100.119 47830 22 TMUX=/tmp/tmux-1000/cloud92.2,4585,0

#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>


int main(int argc, string argv[])
{
  if (argc == 2) {
    for (int i = 0, n = strlen(argv[1]); i < n; i++) { 


       if (i) {
         printf("%s\n", argv[i]);
       }
    }
    return 0;

  } else if (argc > 2) {
    printf("%s", "Usage: ./caesar key \n");

  } else {
    printf("%s", "Usage: ./caesar key\n");

  }

Command Line Output:

$ ./caesar 3uhhhlyffx5bp953azmk976rrctfuuu
3uhhhlyffx5bp953azmk976rrctfuuu 
(null) 
LC_ALL=C.UTF-8 
SSH_CONNECTION=192.168.100.119 47830 192.168.151.248 22 
ISOUTPUTPANE=0 
FLASK_APP=application.py 
LANG=C.UTF-8 
DISPLAY=:0 
EDITOR=nano 
NODE_PATH=/home/ubuntu/.c9/node_modules 
GEM_HOME=/home/ubuntu/.gem 
JAVA_HOME=/opt/jdk-12.0.1 
FLASK_DEBUG=0 
C9_PID=9c83620857724cd7bc928021c3765a39 
CFLAGS=-ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow 
S_COLORS=auto 
NODE_ENV=dev 
CLASSPATH=.:/usr/share/java/cs50.jar 
CC=clang 
FLASK_ENV=development 
USER=ubuntu 
C9_USER=studentRole 
APPLICATION_ENV=dev 
PWD=/home/ubuntu/pset2/caesar 
CHECK50_WORKERS=1 
HOME=/home/ubuntu 
LC_CTYPE=C.UTF-8 
C9_HOSTNAME=6c2d1f21-c253-4199-8cad-61c19b30d4f4-ide.cs50.xyz 
SSH_CLIENT=192.168.100.119 47830 22 
TMUX=/tmp/tmux-1000/cloud92.2,4585,0 
Source Link

Strange CL output

I was testing my code to see if the command line argument's characters are digits but after plugging a random argument that was a mix of letters and numbers, I obtained a strange output. See what you make of it and if you have any idea whats going on, I'd appreciate them

#include <stdio.h>

#include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h>

int main(int argc, string argv[]) { if (argc == 2) { for (int i = 0, n = strlen(argv[1]); i < n; i++) {

   if (i) {
     printf("%s\n", argv[i]);
   }
}
return 0;

} else if (argc > 2) { printf("%s", "Usage: ./caesar key \n");

} else { printf("%s", "Usage: ./caesar key\n");

}

Command Line Output:

$ ./caesar 3uhhhlyffx5bp953azmk976rrctfuuu

3uhhhlyffx5bp953azmk976rrctfuuu (null) LC_ALL=C.UTF-8 SSH_CONNECTION=192.168.100.119 47830 192.168.151.248 22 ISOUTPUTPANE=0 FLASK_APP=application.py LANG=C.UTF-8 DISPLAY=:0 EDITOR=nano NODE_PATH=/home/ubuntu/.c9/node_modules GEM_HOME=/home/ubuntu/.gem JAVA_HOME=/opt/jdk-12.0.1 FLASK_DEBUG=0 C9_PID=9c83620857724cd7bc928021c3765a39 CFLAGS=-ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow S_COLORS=auto NODE_ENV=dev CLASSPATH=.:/usr/share/java/cs50.jar CC=clang FLASK_ENV=development USER=ubuntu C9_USER=studentRole APPLICATION_ENV=dev PWD=/home/ubuntu/pset2/caesar CHECK50_WORKERS=1 HOME=/home/ubuntu LC_CTYPE=C.UTF-8 C9_HOSTNAME=6c2d1f21-c253-4199-8cad-61c19b30d4f4-ide.cs50.xyz SSH_CLIENT=192.168.100.119 47830 22 TMUX=/tmp/tmux-1000/cloud92.2,4585,0