• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

A little C help for my friend

Joined
May 19, 2007
Messages
7,662 (1.24/day)
Location
c:\programs\kitteh.exe
Processor C2Q6600 @ 1.6 GHz
Motherboard Anus PQ5
Cooling ACFPro
Memory GEiL2 x 1 GB PC2 6400
Video Card(s) MSi 4830 (RIP)
Storage Seagate Barracuda 7200.10 320 GB Perpendicular Recording
Display(s) Dell 17'
Case El Cheepo
Audio Device(s) 7.1 Onboard
Power Supply Corsair TX750
Software MCE2K5
He's getting a "multiple declaration for 'printf'" error for this code block, personally i cant see it

Code:
 switch (code)
     {
      	case '1':

          printf:("Very good!!");

          break;

         case '2':

          printf:("Keep it up!!");

          break;

         case '3':

          printf:("Nice job!!");

          break;

          case '4':

          printf:("Excellent");

          break;
     
     }


the erro comes up for the last 3 printf's
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
I'm pretty rusty on my C code, but maybe he could try something like this...
Code:
string CaseReturn;

switch (code)
{
    case '1' :
        CaseReturn = "Very Good!!";
        break;
    case '2' :
        CaseReturn = "Keep it up!!";
        break;
}

printf:(CaseReturn);

Sorry, it's been ages since I've used regular C code. :ohwell:
 

Oliver_FF

New Member
Joined
Oct 15, 2006
Messages
544 (0.08/day)
Processor Intel q9400 @ stock
Motherboard Lanparty P45-T2RS
Cooling Zalman CNPS-9500
Memory 8GB OCZ PC2-6400
Video Card(s) BFG Nvidia GTX285 OC
Storage 1TB, 500GB, 500GB
Display(s) 20" Samsung T200HD
Case Antec Mini P180
Audio Device(s) Sound Blaster X-Fi Elite Pro
Power Supply 700w Hiper
Software Ubuntu x64 virtualising Vista
Code:
printf:("Keep it up!!");

What's with the : after the function name and before the parameters?

Code:
printf("Keep it up!!");
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
I didn't know either, but I wasn't sure if he was using some strange compiler that wanted different syntax or something.
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
27,049 (3.71/day)
Processor Ryzen 7 5700X
Memory 48 GB
Video Card(s) RTX 4080
Storage 2x HDD RAID 1, 3x M.2 NVMe
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 10 64-bit
ummm not printf:

just printf

Code:
switch ('0')
{
  case '1':
    printf("Very good!!");
    break;

I didn't know either, but I wasn't sure if he was using some strange compiler that wanted different syntax or something.
then it wouldn't be c anymore
 
Joined
May 19, 2007
Messages
7,662 (1.24/day)
Location
c:\programs\kitteh.exe
Processor C2Q6600 @ 1.6 GHz
Motherboard Anus PQ5
Cooling ACFPro
Memory GEiL2 x 1 GB PC2 6400
Video Card(s) MSi 4830 (RIP)
Storage Seagate Barracuda 7200.10 320 GB Perpendicular Recording
Display(s) Dell 17'
Case El Cheepo
Audio Device(s) 7.1 Onboard
Power Supply Corsair TX750
Software MCE2K5
damn ... blame the cocomania i was having when he came by and asked me
 
Top