- `#include <cs50.h>
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int main (int argc, string argv[]) // how to implement argc2?
- {
-
if(argc!=2) // how to know more than 1 number was putted?
-
-
printf("error : You should put 1 non-negative integer");
-
-
-
**int number = &argv[1];** : argv[1]에 입력된 값을 number라는 변수로 사용하고 싶습니다.
-
-
string pltxt = get_string();
-
-
-
// get remainder of number devided by 26
-
for (int i=0, n=strlen(pltxt); i<n; i++) //iterate over the letter of pltxt
-
-
if (!isalpha(pltxt[i])) // see if i'th word is letter or not
-
-
-
-
-
-
key=pltxt[i]-'a'; // difference btween pltxt and a
-
cptxt[i]=(key+number)%26+'a'; // add residual of (key+numner)/26 to a
-
-
-
-
key=pltxt[i]-'A'; // diff between pltxt and A
-
cptxt[i]=(key+number)%26+'A';
-
-
-
-
-
- }`
이랬을 때 에러가
caeser.c:18:13: error: incompatible pointer to integer conversion initializing 'int' with an expression of
type 'string *' (aka 'char **') [-Werror,-Wint-conversion]
int number = &argv[1];
^ ~~~~~~~~
2 errors generated.
make: *** [caeser] Error 1
라고 뜨네요.
중간에 지워버린 코드가 있는데
if (&argv[1]<'0')
{
printf("error: You should put 1 non-negative integer");
return 1;
}
이 코드를 돌렸을 때도 argv[1]이 참조변수라서
caeser.c:13:21: error: ordered comparison between pointer and integer ('string *' (aka 'char **') and 'int')
[-Werror]
if (&argv[1]<'0')
이라고 뜨더라구요
그래서 argv[1]의 값을 int number라는 값변수에 저장하고 싶은데 &나 * 둘 중 하나를 사용하면 되는건가요?
이랬을 때 에러가
caeser.c:18:13: error: incompatible pointer to integer conversion initializing 'int' with an expression of
type 'string *' (aka 'char **') [-Werror,-Wint-conversion]
int number = &argv[1];
^ ~~~~~~~~
2 errors generated.
make: *** [caeser] Error 1
라고 뜨네요.
중간에 지워버린 코드가 있는데
if (&argv[1]<'0')
{
printf("error: You should put 1 non-negative integer");
return 1;
}
이 코드를 돌렸을 때도 argv[1]이 참조변수라서
caeser.c:13:21: error: ordered comparison between pointer and integer ('string *' (aka 'char **') and 'int')
[-Werror]
if (&argv[1]<'0')
이라고 뜨더라구요
그래서 argv[1]의 값을 int number라는 값변수에 저장하고 싶은데 &나 * 둘 중 하나를 사용하면 되는건가요?