0

I'm new to this and this is the code ive written and cant figureout what i need to do to fix it. any help would be appreciated thank you

#include <cs50.h>
#include <stdio.h>
#include <math.h>

int main(void)
{

   printf("how many minutes is your shower: ");
   int shower = GetInt();

  int a = shower * 192;

   int y = 16;

    printf("The amount of water bottles used for your shower is %d\n", x, a/y);
}

this is what i get when i type in make water

clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall-Werror -Wextra -Wno-sign-compare -Wshadow    water.c  -lcrypt -lcs50 -lm -o water
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gn u/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
 /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
 (.text+0x20): undefined reference to `main'
 clang: error: linker command failed with exit code 1 (use -v to see  invocation) make: *** [water] Error 1
0

This is the kind of error that shows up when trying to build a source code file that doesn't have a main() function. Is it possible that you started with water() instead of main(), changed it, and forgot to save the updated source code file before trying to build it?

Or maybe you're not compiling the correct source code file because you have another version in another directory?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

| improve this answer | |
  • so i changed int main(void) to int water(void) and get a new set of errors. and im taking steps backwards? – tanderson Nov 30 '16 at 20:10
  • ~/workspace/pset1/ $ make water clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow water.c -lcrypt -lcs50 -lm -o water water.c:15:80: error: data argument not used by format string [-Werror,-Wformat-extra-args] printf("The amount of water bottles used for your shower is %d\n", shower, a/y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ water.c:16:1: error: control reaches end of non-void function [-Werror,-Wreturn-type] } ^ 2 errors generated. make: *** [water] Error 1 – tanderson Nov 30 '16 at 20:10
  • You're going forward. Sometimes, one error can mask a bunch of other errors. You just have to work your way through them. This will help with one of them: cs50.stackexchange.com/questions/2448/… – Cliff B Nov 30 '16 at 20:23
  • never mind i fixed an error. i have 2 different errors now error: data argument not used by format string [-Werror,-Wformat-extra-args] printf("The amount of waterbottles used for your shower is: %d\n", shower, a/y) error: control reaches end of non-void function [-Werror,-Wreturn-type] – tanderson Nov 30 '16 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .