Print slashes using C


 
Thread Tools Search this Thread
Top Forums Programming Print slashes using C
# 1  
Old 05-14-2013
Code Print slashes using C

I want to print 4052 slashes using this C program.
Code:
#include <stdio.h>

void main()
{
int i;
for (i=0; i<4052; i++)
printf ("/");

}

When i compile this via gcc am getting this error :
Image

Can anyone point out what am doing wrong?

Last edited by vish6251; 05-14-2013 at 11:13 AM..
# 2  
Old 05-14-2013
Try:-

Code:
#include <stdio.h>

void main()
{
        int i;
        for (i=0; i<4052; i++)
        {
                printf ("/");
        }
}

This User Gave Thanks to wisecracker For This Post:
# 3  
Old 05-14-2013
Quote:
Originally Posted by wisecracker
Try:-

Code:
#include <stdio.h>

void main()
{
        int i;
        for (i=0; i<4052; i++)
        {
                printf ("/");
        }
}

It worked man thanks a lot!! can you tell me whats the difference between my program and yours? I tried to put curly braces earlier but didn't work :/
# 4  
Old 05-14-2013
I don't see any.

In fact, your program works.

Did you post it completely as-is or clean it up?
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 05-14-2013
Quote:
Originally Posted by Corona688
I don't see any.

In fact, your program works.

Did you post it completely as-is or clean it up?
My program was correct but didn't work for some strange reasons. After I cleaned it up (added tabs and braces) it worked perfectly.
thank you for reply mate Smilie
# 6  
Old 05-14-2013
Quote:
Originally Posted by vish6251
My program was correct but didn't work for some strange reasons.
Very odd. I copy-pasted it and it just worked here. Oh well!
# 7  
Old 05-14-2013
I don't believe that the program in post #1 generated the warning in the screenshot. Note that the warning uses the word "parameter", which is a strong clue. I'll wager that the program that actually generated that message defined main() using pre-ANSI syntax, which is what happens if int i; is moved up a line, so that it resides outside the braces.
Code:
void main()
int i;
{
    ...
}

Regards,
Alister
This User Gave Thanks to alister For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to extract the data between slashes

I have got the following contents and please can you advise me on how to extract the following data that appears between the very first slashes. Thanks i.e 576 , 10000, 1299 3/576/GPP///////NONE/0 50/10000/GPP///D4////GPP/0 234/1299/GPP///////NONE/0 (3 Replies)
Discussion started by: Sudhakar333
3 Replies

2. Cybersecurity

Server is ignoring slashes

When I try to access my website's Administrator page (mysite.com/administrator), I'm redirected to (mysite.comadministrator), as if the slash was removed from the URL The funny thing is that I can access it if I enter 2 slashes (mysite.com//administrator) Any ideas of what might be causing it? (4 Replies)
Discussion started by: rlopes
4 Replies

3. Shell Programming and Scripting

How to use sed when a match has forward slashes

I'm trying to replace an alias with its match using sed but the match contains forward slashs so it causes the sed command to throw a garbled message.. cmd_list.txt sample AIX_myserver_1011_vintella.sudoers_cmndalias sample I'm trying to use the below but like I say it throws a... (5 Replies)
Discussion started by: Jazmania
5 Replies

4. Shell Programming and Scripting

question on blackslashes and slashes in directories

Since I'm usually on windows I've came across different shells like Cygwin, Hamilton, and MKS. I've been working in csh most of the time, so porting scripts from one shell to another can be fairly annoying and confusing. When specifying a directory I noticed that certain shells do not recognize... (1 Reply)
Discussion started by: vas28r13
1 Replies

5. Shell Programming and Scripting

search replace pattern containing slashes

Need help in finding pattern then replacing pattern that contains multiple slashes .. ex . <imgp src="Attention_web.eps.jpg" align="left"> <imgp src="NewToday062308.eps.jpg"> replace with <imgp src="/ww2/adpay/liner/Attention_web.eps.jpg" align="left"> <imgp... (2 Replies)
Discussion started by: aveitas
2 Replies

6. UNIX for Dummies Questions & Answers

dots and slashes

when I execute a command in like "run.sh," I can run it two ways: ./run.sh or . run.sh What is the difference? (1 Reply)
Discussion started by: DarkLord
1 Replies

7. UNIX for Dummies Questions & Answers

sed command for using with back slashes

hi all, im trying to use a sed command to remove all occurenes of \p\g what i used so far is : sed 's!\p\g!!g' file but this doesnt work ? Any ideas, thanks for helping. (2 Replies)
Discussion started by: seaten
2 Replies

8. UNIX for Dummies Questions & Answers

Password slashes.

Hi everyone! :) I've been asked to write an article breaking down the basics of UNIX password information etc., and I've come across something in which I cannot find a definition for within Google. Very simply, can anyone tell me what the difference is between a standard UNIX password, and... (4 Replies)
Discussion started by: hellz
4 Replies

9. Shell Programming and Scripting

slashes in a bash shell

Substituting the / for the \ I came up with this: sed s/\\\\usr\\\\qm/\\\\\\\\qmi/g Can anyone explain to me please, why I have to pass the slash four times? :confused: (2 Replies)
Discussion started by: Shakey21
2 Replies

10. UNIX for Dummies Questions & Answers

UNIX and forward slashes

Hey, This is probably going to sound like an immensely stupid and dull question, but can someone please tell me whether the forward slash on the web address (http://) signifies that it is running on UNIX? hanks (1 Reply)
Discussion started by: steverocliffe
1 Replies
Login or Register to Ask a Question